I have following code:
#include
#include
template< int I, int J >
struct Base
{
};
#define SEQ ( 1 ) ( 2 ) ( 3 ) ( 4 )
#define OP( s, data, elem ) Base< elem, elem >
struct Derived
: BOOST_PP_SEQ_ENUM( BOOST_PP_SEQ_TRANSFORM( OP, nil, SEQ ) )
{
};
The Derived has bases classes generated from a sequence (SEQ). The bases
classes themselves are instantiations of Base template type. I expected the
code to be preprocessed into something like (just the important part):
struct Derived
: Base< 1, 1 >, Base< 2, 2 >, Base< 3, 3 >, Base< 4, 4 >
{
};
but instead it is preprocessed into:
struct Derived
: Base< 1, Base< 2, Base< 3, Base< 4
{
};
This obviously is caused by Base being template with to parameters and thus
having a comma.
Adding parenthesis around Base in OP solves the issue by generating
expected code fully. But it still does not compile because parenthesis are
not allowed in that place (base classes list).
Is there any other workaround? How to deal with it?