From 02497657796e891a6dfb8dd0285638104db6c773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E6=99=93=E4=BC=9F?= <39303645+Shixiaowei02@users.noreply.github.com> Date: Tue, 8 Sep 2020 21:15:56 +0800 Subject: [PATCH] fix constexpr definitions bug in class, test=develop (#4267) --- lite/model_parser/base/traits.h | 40 ++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/lite/model_parser/base/traits.h b/lite/model_parser/base/traits.h index 09ac80ddc9..275bb21cb6 100644 --- a/lite/model_parser/base/traits.h +++ b/lite/model_parser/base/traits.h @@ -119,22 +119,30 @@ class VectorView; template struct OpDataTypeTrait; -#define ATTR_TYPE_TRAIT_IMPL(T, type__) \ - template \ - struct OpDataTypeTrait { \ - typedef type__ ET; \ - typedef type__ RT; \ - static constexpr OpAttrType AT = OpAttrType::T; \ - static constexpr const char* ATN = #T; \ - }; -#define ATTR_VECTOR_TYPE_TRAIT_IMPL(T, type__) \ - template \ - struct OpDataTypeTrait, U> { \ - typedef type__ ET; \ - typedef VectorView RT; \ - static constexpr OpAttrType AT = OpAttrType::T; \ - static constexpr const char* ATN = #T; \ - }; +#define ATTR_TYPE_TRAIT_IMPL(T, type__) \ + template \ + struct OpDataTypeTrait { \ + typedef type__ ET; \ + typedef type__ RT; \ + static constexpr OpAttrType AT{OpAttrType::T}; \ + static constexpr const char* ATN{#T}; \ + }; \ + template \ + constexpr OpAttrType OpDataTypeTrait::AT; \ + template \ + constexpr const char* OpDataTypeTrait::ATN; +#define ATTR_VECTOR_TYPE_TRAIT_IMPL(T, type__) \ + template \ + struct OpDataTypeTrait, U> { \ + typedef type__ ET; \ + typedef VectorView RT; \ + static constexpr OpAttrType AT{OpAttrType::T}; \ + static constexpr const char* ATN{#T}; \ + }; \ + template \ + constexpr OpAttrType OpDataTypeTrait, U>::AT; \ + template \ + constexpr const char* OpDataTypeTrait, U>::ATN; ATTR_TYPE_TRAIT_IMPL(BLOCK, int16_t); ATTR_TYPE_TRAIT_IMPL(INT, int32_t); -- GitLab