
On 05/08/2012 12:12 PM, Daniel James wrote:
There's BOOST_PP_IS_EMPTY in <boost/preprocessor/facilities/is_empty.hpp> although it isn't publicized as it won't work on some preprocessors. I haven't look closely enough to see how it compares. Cool, thanks! This one really does a lot of compiler checks and mine is gcc-specific. I came up with a much better variation (below). As far as the standards, I think an empty pre-processor parameter is only well-formed in C++03 or 11 and in C99 and later.
#define __JUNK junk, #define _iff_empty(arg1_or_junk, t, f) __iff_empty(arg1_or_junk, f, t) #define __iff_empty(__ignored1, __ignored2, result, ...) result #define IFF_EMPTY(test, t, f) _iff_empty(__JUNK##test, t, f) #define IS_EMPTY(test) IFF_EMPTY(test, 1, 0) While this works in gcc, it doesn't deal with any compiler quirks & differences, sorry. Daniel