Boost logo

Boost Users :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-10-02 20:29:43


Michael Fawcett wrote:
> On 10/2/07, Josh Brown <jbrown_at_[hidden]> wrote:
>> The root of my problem seems to stem from the fact that BOOST_PP_IF
>> expands both the true and false expressions before it does the if test
>> and just outputs the already expanded expression. Is this correct; and
>> if so, is there a way around it?

Make the IF lazy.

>> Or are there any obvious other
>> solutions to my problem that the boost experts can suggest :)
>
> You'll want to look into BOOST_PP_TUPLE_EAT -
> http://www.boost.org/libs/preprocessor/doc/ref/tuple_eat.html
>

Exactly.

     #define GET_OPTIONAL_ELEMENT(r, data, elem) \
         BOOST_PP_IF( \
             BOOST_PP_EQUAL(BOOST_PP_SEQ_SIZE(elem), 3), \
             BOOST_PP_SEQ_ELEM, BOOST_PP_TUPLE_EAT(2) \
         )(2,elem)

Regards,
Tobias


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