|
Boost : |
From: Peder Holt (peder.holt_at_[hidden])
Date: 2005-09-14 05:22:34
On 9/14/05, Jason Hise <chaos_at_[hidden]> wrote:
> Background: I am using a few functions which have the following form:
>
> void create ( );
>
> template < typename P1 >
> void create ( P1 p1 );
>
> template < typename P1, typename P2 >
> void create ( P1 p1, P2 p2 );
> [...]
>
> I am trying to generate these using the boost preprocessor library, but
> I am getting an error. This is probably because I do not fully
> understand how the order of expansion of function-like macros works.
> The error is:
> warning C4002: too many actual parameters for macro 'BOOST_PP_IIF_1'
>
> My code is as follows:
>
> #define BOOST_PP_LOCAL_LIMITS (0,
> BOOST_SINGLETON_PTR_MAX_CONSTRUCTOR_PARAMS)
> #define BOOST_PP_LOCAL_MACRO(n) \
> BOOST_PP_IF(n, template < BOOST_PP_ENUM_PARAMS(n, typename P) >, \
> BOOST_PP_EMPTY()) void create ( BOOST_PP_ENUM_BINARY_PARAMS(n, \
> typename ::boost::call_traits < P, >::param_type p ) ) \
> { \
> policy_ptr->get_creator ( )->create \
> ( BOOST_PP_ENUM_PARAMS(n, p) ); \
> }
> #include BOOST_PP_LOCAL_ITERATE()
>
> What am I doing wrong?
Try replacing
BOOST_PP_IF with BOOST_PP_EXPR_IF:
BOOST_PP_EXPR_IF(n, template < BOOST_PP_ENUM_PARAMS(n, typename P) >)\
If I understand it correctly,
BOOST_PP_EMPTY() expands to nothing before BOOST_PP_IF is called,
causing BOOST_PP_IF to be called with:
BOOST_PP_IF(n, template < BOOST_PP_ENUM_PARAMS(n, typename P) >,)
Regards,
Peder
>
> -Jason
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk