Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-07-25 04:51:55

Jaap Suter wrote:
> Another idea/problem:
> What about creating a union of all members in a typelist? Is
> that possible?

Not a C++ union. Consider using a 'variant' class :). Alternatively, you can
do it with Preprocessor library:

    union my
        #define UNION_MEMBER(R,name,i,type) type BOOST_PP_CAT(name,i);
            , field
            , BOOST_PP_TUPLE_TO_LIST(3,(int,long,bool))
        #undef UNION_MEMBER

which will produce you this:

    union my
        int field0;
        long field1;
        bool field2;


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