|
Boost Users : |
Subject: [Boost-users] [Preprocessor] Comma in sequence element
From: Adam Badura (abadura_at_[hidden])
Date: 2013-02-12 12:53:22
I have following code:
#include <boost/preprocessor/seq/enum.hpp>
#include <boost/preprocessor/seq/transform.hpp>
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?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net