Boost logo

Boost Users :

From: Paul Grenyer (paul_at_[hidden])
Date: 2004-02-07 08:44:06


Hi All

I fear I may be trying to get a square peg in a round hole, but here goes
anyway...

I'm trying to use the boost PreProcessor library to generate constructors
with varying numbers of parameters. I've tried the following:

#include <boost/preprocessor/arithmetic/inc.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/repetition.hpp>

#ifndef MAX_CONCRETE_CONSTRUCTOR_PARAMS
#define MAX_CONCRETE_CONSTRUCTOR_PARAMS 3
#endif

#define CONCRETE_CONSTRUCTOR(Z, N, _) \
    template<class R BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, class A)>
\
    explicit Concrete( BOOST_PP_ENUM_PARAMS(N, A) ) \
    { }

class Concrete
{
public:
    BOOST_PP_REPEAT(BOOST_PP_INC(MAX_CONCRETE_CONSTRUCTOR_PARAMS),
CONCRETE_CONSTRUCTOR, _)
};

int main()
{
    Concrete a( 1, 2 );
    return EXIT_SUCCESS;
}

But this gives me the following error:

    error C2660: 'Concrete::Concrete' : function does not take 2 arguments

I have feeling I'm doing something very wrong or that can't be done.

Regards
Paul

Paul Grenyer
Email: paul_at_[hidden]
Web: http://www.paulgrenyer.co.uk

Have you met Aeryn: http://www.paulgrenyer.co.uk/aeryn/?
Version 0.3.0 beta now ready for download


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