Boost logo

Boost Users :

From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2007-06-19 02:44:17


> Take a look at this: #define SPECIAL
> #define IS_SPECIAL(x) BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY() x)#define MACRO
(i,z,array) IS_SPECIAL( BOOST_PP_ARRAY_ELEM(i, array) )
> #define ENUM( n, tuple ) BOOST_PP_ENUM( n, MACRO, (n, tuple) )ENUM( 3, (
arg1,        , arg3) ) //1
> ENUM( 3, ( arg1, SPECIAL, arg3) ) //2 In this context, can we safely say
that 2 complies with standards more than 1?cheers, L. 

Both should be rejected by C++ standard conformant compiler. Although all
compilers I'm aware of successfully compile this code (some of them produce
warning).

Here are examples of empty macro arguments processing.

Example 1:

#define A(x)
#define B
A(B) // ok

Example 2:

#define A1(x)
#define A(x) A1(x)
#define B
A(B) // error because of double expansion

Both examples are standard conforming for C99 preprocessor and C++0x
preprocessor. Although second example is not standard conforming for C++03
preprocessor.

Roman Perepelitsa.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net