From 62439007b4f59e863fc659e848eb28c0a31beb24 Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Tue, 14 May 2019 11:47:49 +0200 Subject: [PATCH] Allow macros to be passed to macro DEFINE_HAS_MEMBER_TRAITS Before this change the preprocessor choked on macros or function macros being passed to DEFINE_HAS_MEMBER_TRAITS. That made it impossible to generate template class names that e.g. make use of the __COUNTER__ macro. Signed-off-by: Florian Fleissner --- src/kaleidoscope_internal/type_traits/has_member.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/kaleidoscope_internal/type_traits/has_member.h b/src/kaleidoscope_internal/type_traits/has_member.h index 08fded33..03f8fa33 100644 --- a/src/kaleidoscope_internal/type_traits/has_member.h +++ b/src/kaleidoscope_internal/type_traits/has_member.h @@ -36,6 +36,8 @@ // explain what it does. But the explanations are good enough to actually // understand what's going on. +#define CAT3(A, B, C) A##B##C + #define DEFINE_HAS_MEMBER_TRAITS(PREFIX, MEMBER_NAME) __NL__ \ __NL__ \ /* This defines a templated class PREFIX##_HasMember_##MEMBER_NAME. __NL__ \ @@ -44,7 +46,7 @@ * string tokens to form new identifiers (here the struct name). __NL__ \ */ __NL__ \ template __NL__ \ - struct PREFIX##_HasMember_##MEMBER_NAME { __NL__ \ + struct CAT3(PREFIX, _HasMember_, MEMBER_NAME) { __NL__ \ __NL__ \ /* This code defines an inner class, Fallback, with one __NL__ \ * member – named MEMBER_NAME (remember that MEMBER_NAME is a __NL__ \