Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2003-04-17 17:51:08


Terje Slettebø wrote:

>> MACRO( IN(2, (std::pair<int, int>)) )
>
> I'm not sure how this latter solution could be used. How could MACRO
> retrieve the type being passed?

You have to encode the type in a structure, and then decode it when you actually
need it:

#define IN(s, x) (s) x
#define OUT(type) BOOST_PP_TUPLE_REM type

#define MACRO(z, i, type) \
    BOOST_PP_CAT(class T, i) = OUT(type) \
    /**/

template<
    BOOST_PP_ENUM(
        3, MACRO,
        IN(2, (std::pair<int, int>))
    )
> class xyz;

Passing in an intermediate value like this:

#define ID2(a, b) a, b
#define MACRO(x) x

MACRO( ID2( std::pair<int, int> ) )

...is error prone (and dangerous). :(

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