
Quoting Reimund Klemm <klemm@ifn.et.tu-dresden.de>:
Why does this example compile with an error?:
#include <boost/preprocessor/seq/subseq.hpp> #include <boost/preprocessor/seq/seq.hpp> #include <boost/preprocessor/control/if.hpp>
#define SEQ (b)(o)(o)(s)(t) #define i 0
int main( int argc, char* argv[]){ BOOST_PP_IF(i,BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_SUBSEQ(SEQ, 0, i)),0); return 0; }
You need to delay the evaluation of the branches. E.g. #include <boost/preprocessor/seq/subseq.hpp> #include <boost/preprocessor/seq/seq.hpp> #include <boost/preprocessor/control/if.hpp> #define SEQ (b)(o)(o)(s)(t) #define i 0 #define TRUE_BRANCH(SEQ)\ BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_SUBSEQ(SEQ,0,i))\ /**/ #define FALSE_BRANCH(SEQ) 0 int main( int argc, char* argv[]){ BOOST_PP_IF(i,TRUE_BRANCH,FALSE_BRANCH)(SEQ); return 0; } should work. Pete