I wrote this variadic macro template<>
-maker.
#define TNAME0()
#define TNAME1(_1) typename _1
#define TNAME2(_1,_2) typename _1, typename _2
#define TNAME3(_1,_2,_3) typename _1, typename _2, typename _3
#define TYPENAMES(_0,_1,_2,_3,n,...) TNAME##n
#define T(types...) template< TYPENAMES(,##types,3,2,1,0)(types) >
It works great with GNU C++ (e.g. T()
,T(U)
,T(U,V)
,...), but fails with 0 args using ISO C++ standard (calls TYPES1
instead of TYPES0
).
Is there a fix that works with both GNU and ISO c++?
__VA_OPT__
, there is no standard-compliant way to have the preprocessor do different things withT()
andT(Arg)
.