|
Boost Users : |
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-01-28 13:12:16
AMDG
Ovanes Markarian wrote:
> Hello *,
>
>
> I have some pre-processor sequence in form of:
>
> (X1) (X2) (X3) (X4)
>
> which is expanded by BOOST_PP_SEQ_FOR_EACH to template parameters:
>
> some_template<X1, X2, X3, X4> ...
>
>
> My problem now is that some of Xn parameters can be a template
> instantiation and that actually causes PP to think, that there are
> more parameters to the function applied by ..._SEQ_FOR_EACH.
> Example: some_other_template<T1, T2> cause preprocessor to think that
> there are 2 params some_other_template<T1 and T2>.
>
> Putting the parameter into additional braces like ((X4)) results in
> the template:
>
> some_template<X1, X2, X3, (X4)> and that results in a compiler error.
> I know this construct can switch off ADL, but I don't know why it
> result here in a compiler error, since I fully qualify the X4 (from
> which namespace it is). Is there any way to treat Xn as a single
> paramer but during the final pre-processing stage get rid of
> additional braces?
>
There are a couple of ways to do it. You can make each element of the
Seq to be itself a seq
and then call BOOST_PP_SEQ_ENUM on the inside:
((X1)) ((X2)) ((some_other_template<T1)(T2>))
Another way is to use template metaprogramming
(X1)(X2)(parenthesize_type(wrap<some_other_template<T1, T2>>))
template<class T>
struct unparenthesize { typedef T type; };
template<class T>
struct unparenthesize<parenthesized_type(wrap<T>)> { typedef T type; };
In Christ,
Steven Watanabe
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