|
Boost : |
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2006-01-29 12:11:42
> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Tobias Schwinger
> Paul Mensonides wrote:
> > BOOST_PP_IF(
> > n,
> > BOOST_PP_TUPLE_EAT,
> > BOOST_PP_TUPLE_REM
> > )(1)( EXPENSIVE_MACRO_INVOCATION() )
> >
> > ...where EXPENSIVE_MACRO_INVOCATION() is only invoked if 'n' is 0.
>
> Guessing from the overtone of your comment it would be better to say
>
> BOOST_PP_IF(n, BOOST_PP_TUPLE_EAT(0), EXPENSIVE_MACRO_INVOCATION)()
>
> to be on the safe side with less compliant preprocessors. Correct?
Yes. It's also just better. Sorry, it is getting late in the morning here, and
I haven't slept yet.
> ---
>
> #define MACRO(x) x
> MACRO(BOOST_PP_EMPTY())
>
> BTW. is this special case safe (theoretically and
> practically, that is)?
On a good preprocessor, it's safe. Broken preprocessors tend to allow empty
arguments anyway, so it should be safe there too.
Regards,
Paul Mensonides
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk