From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2005-09-14 08:10:59


> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Jason Hise

> 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())

Two problems here... IF forwards its arguments to IIF, however, before it can
do so, 1) ENUM_PARAMS is creating 'n' arguments and 2) EMPTY() is expanding to
nothing. This definitely won't work. You need something like:

IF(n, template < ENUM_PARAMS, TUPLE_EAT(2))(n, typename P) EXPR_IF(n, >)

> 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?

The better way to go, IMO, is to take the non-template special case out of the
generation algorithm--which simplies it. E.g.

void create()
{
    policy_ptr->get_creater()->create();
}

#define LOCAL_LIMITS (1, MAX_PARAMS)
#define LOCAL_MACRO(n) \
    template< ENUM_PARAMS(n, typename P) > \
    void create( \
        ENUM_BINARY_PARAMS( \
            n, \
            typename ::boost::call_traits<P, >::param_type p \
        ) \
    ) \
    { \
        policy_ptr->get_creater()->create( \
            ENUM_PARAMS(n, p) \
        ); \
    } \
    /**/
#include LOCAL_ITERATE()

Is there more to this code than what you actually have here? It seems like
there should be.

Regards,
Paul Mensonides