Boost logo

Boost :

Subject: Re: [boost] [preprocessor] automatic recursion curiosity
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2012-09-14 13:40:50


AMDG

On 09/14/2012 09:24 AM, Lorenzo Caminiti wrote:
> Hello all,
>
> I have a curiosity about an implementation detail of
> Boost.Preprocessor: How does the lib implement Automatic Recursion?
>
> <snip>
>

It looks something like this:

#define TEST_BOOST_PP_REPEAT_1(n, macro, data) 0
#define TEST_OKAY(z, n, data) 1

// expands to 1 if we BOOST_PP_REPEAT_1 is available
BOOST_PP_CAT(TEST_, BOOST_PP_REPEAT_1(1, OKAY, ~))

There's some extra magic around this using
BOOST_PP_AUTO_REC to find the smallest available
dimension.

In Christ,
Steven Watanabe


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