Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2006-01-28 10:38:03


Arkadiy Vertleyb wrote:
> Hi,
>
> The following code:
>
> #include <boost/preprocessor/control/if.hpp>
> #include <boost/preprocessor/enum_params.hpp>
> BOOST_PP_ENUM_PARAMS(3, p)
> BOOST_PP_IF(1, BOOST_PP_ENUM_PARAMS(3, p), blah)
>
> results in the following text (vc71, main CVS):
>
> p0 , p1 , p2
> p0
>
> and a warning:
>
> to many parameters for BOOST_PP_IIF_1.
>
> What's wrong?

"Being lazy" solves the problem:

  #include <boost/preprocessor/control/if.hpp>
  #include <boost/preprocessor/enum_params.hpp>
  #include <boost/preprocessor/tuple/eat.hpp>

  BOOST_PP_ENUM_PARAMS(3, p)
  BOOST_PP_IF(1, BOOST_PP_ENUM_PARAMS, blah BOOST_PP_TUPLE_EAT(2))(3,p)

Note:
- BOOST_PP_IF does not get disabled
- lazy invocation => no repetition in the "else-case".

Regards,

Tobias


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk