I have the following macro:
#define REFLECTABLE(...) \
REFLECTABLE_CONST(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__)==0, __VA_ARGS__)
I ran the pre-processor. It passes to REFLECTABLE_CONST
3==0
instead of 0
or false
. In REFLECTABLE_CONST
, I am using that value to simulate a conditional as described in this post. So, I need the pre-processor to pass a value. Is there a way to make pre-processor substitute things like 3==0
by false
or 0
?
I couldn't reproduce BOOST_PP_VARIADIC_SIZE
being able to have a result of 0
, but if you can, this should work:
#define IS_EMPTY_IMPL0 1
#define IS_EMPTY_IMPL1 0
#define IS_EMPTY_IMPL2 0
#define IS_EMPTY_IMPL3 0
#define IS_EMPTY_IMPL4 0
#define IS_EMPTY_IMPL5 0
#define IS_EMPTY_IMPL6 0
#define IS_EMPTY_IMPL7 0
#define IS_EMPTY_IMPL8 0
#define IS_EMPTY_IMPL9 0
#define IS_EMPTY(...) BOOST_PP_CAT(IS_EMPTY_IMPL, BOOST_PP_VARIADIC_SIZE(__VA_ARGS__))
#define REFLECTABLE(...) \
REFLECTABLE_CONST(IS_EMPTY(__VA_ARGS__), __VA_ARGS__)
Stumbled upon this solution. Just use this instead:
#define REFLECTABLE(...) \
REFLECTABLE_CONST(BOOST_PP_IS_EMPTY(__VA_ARGS__), __VA_ARGS__)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.