|
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);
BOOST_PP_LIST_FOR_EACH_I(
UNION_MEMBER
, 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;
};
Aleksey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk