Define: is there a way to expand the arguments?

T() - macro

I have a lot of things, like:

MACRODOWN(T(P), T(E), T(X), T(R), T(T), T(H), T(A), T(F))
MACRODOWN(T(H), T(A), T(F))
MACRODOWN(T(Z), T(A))

I would like to define a macro that will work as follows:

MACRODOWN(TT(P,E,X,R,T,H,A,F))
MACRODOWN(TT(H,A,F))
MACRODOWN(TT(Z,A))

And they, of course, would rule out the first macros above. Is this possible, and if so, how?

+4
source share
2 answers

: , GCC . C 2 : , , , . , , - . - , . , , , , , . GCC (https://gcc.gnu.org/), , , , , . GCC ( : https://gcc.gnu.org/onlinedocs/cpp/Macros.html), . , , , , , .

0

#include <boost/preprocessor/variadic/to_seq.hpp>
#include <boost/preprocessor/seq/enum.hpp>
#include <boost/preprocessor/seq/transform.hpp>


#define TT(...) BOOST_PP_SEQ_ENUM( BOOST_PP_SEQ_TRANSFORM( TT_, _, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__) ) )
#define TT_(_1,_2,E) T(E)

TT(A,B,C,D) // T(A),T(B),T(C),T(D)

pp.

0

Source: https://habr.com/ru/post/1686460/


All Articles