On 6/18/07, Tobias Schwinger
Roman Perepelitsa wrote:
Tobias Schwinger
writes: Yep, here's another dirty trick :
#include
#define SPECIAL (whatever) #define IS_SPECIAL BOOST_PP_IS_UNARY
IS_SPECIAL(a) // 0 IS_SPECIAL(b) // 0 IS_SPECIAL(SPECIAL) // 1
It isn't entirely portable to older preprocessors (that's why this code lives in preprocessor/detail) but should work with latest versions of the widely-used compilers.
This also works:
#include
#include #define SPECIAL #define IS_SPECIAL(x) BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY() x)
Yep, that's even better as it allows x to be anything. Got some idea how portable it is?
Well, IS_UNARY trick also works for pretty much anything except maybe another non-SPECIAL unary. What exactly is the offending code in BOOST_PP_IS_UNARY that makes it non-portable? -- Server Levent Yilmaz Mechanical Engineering University of Pittsburgh