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) \

        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> ) ) error prone (and dangerous). :(

Paul Mensonides

Boost list run by bdawes at, gregod at, cpdaniel at, john at