How to use boost preprocessor to generate accessors?

Disclaimer:You should probably wait in case a better answer appears even if you are satisfied with this answer, because I’m far from an expert and these may not be the best approaches. 1st approach: //two different sequences struct A { MY_MACRO1((int)(float)(double),(x)(y)(z)) }; I think this approach gives the less scary-looking macro: #define DECLARE_DATA_MEMBER1(R,TYPES,INDEX,NAME) \ BOOST_PP_SEQ_ELEM(INDEX,TYPES) … Read more

Is the C99 preprocessor Turing complete?

Well macros don’t directly expand recursively, but there are ways we can work around this. The easiest way of doing recursion in the preprocessor is to use a deferred expression. A deferred expression is an expression that requires more scans to fully expand: #define EMPTY() #define DEFER(id) id EMPTY() #define OBSTRUCT(…) __VA_ARGS__ DEFER(EMPTY)() #define EXPAND(…) … Read more