[parameter] Boost.Parameter Constructors in Template Classes
Hi Everyone, I'm not sure whether this is more appropriate for the users list or the developers list so I sent the email to both. I'm using Boost's SVN Trunk r66609 and I tried to compile the (attached) file to follow the pattern described by the Boost.Parameter tutorial (http://www.boost.org/doc/libs/1_44_0/libs/parameter/doc/html/index.html#para...) but unfortunately I get an error deep in the preprocessor code that Boost.Parameter uses. What I'm trying to do is to make a template class support parameterized constructors, and only have optional parameters and no required ones. The idea is: template <class Tag> struct base; template <class Tag> struct derived : base<Tag> { BOOST_PARAMETER_CONSTRUCTOR(...); }; Has anybody been able to make this work? Thanks and I definitely hope to hear from you soon. PS. I am also going to file this as a bug in Boost.Parameter so that it doesn't get lost in the mailing list churn. ;) -- Dean Michael Berris deanberris.com
At Tue, 16 Nov 2010 16:59:47 +0800, Dean Michael Berris wrote:
I'm not sure whether this is more appropriate for the users list or the developers list so I sent the email to both. I'm using Boost's SVN Trunk r66609 and I tried to compile the (attached) file to follow the pattern described by the Boost.Parameter tutorial (http://www.boost.org/doc/libs/1_44_0/libs/parameter/doc/html/index.html#para...) but unfortunately I get an error deep in the preprocessor code that Boost.Parameter uses.
1. What is the error? 2. Have you tried looking at the output of the preprocessor to see what might be happening? -- Dave Abrahams BoostPro Computing http://www.boostpro.com
On Tue, Nov 16, 2010 at 6:00 PM, David Abrahams
At Tue, 16 Nov 2010 16:59:47 +0800, Dean Michael Berris wrote:
I'm not sure whether this is more appropriate for the users list or the developers list so I sent the email to both. I'm using Boost's SVN Trunk r66609 and I tried to compile the (attached) file to follow the pattern described by the Boost.Parameter tutorial (http://www.boost.org/doc/libs/1_44_0/libs/parameter/doc/html/index.html#para...) but unfortunately I get an error deep in the preprocessor code that Boost.Parameter uses.
1. What is the error?
With GCC 4.4 on Ubuntu I get: boost_parameter_template.cpp:24: error: macro "BOOST_PARAMETER_FOR_EACH_pred_aux2" passed 3 arguments, but takes just 2 boost_parameter_template.cpp:24: error: macro "BOOST_PP_SPLIT_0" requires 2 arguments, but only 1 given boost_parameter_template.cpp:24: error: macro "BOOST_PP_SEQ_ELEM_III" requires 2 arguments, but only 1 given boost_parameter_template.cpp:24: error: macro "BOOST_PP_SEQ_ELEM_III" requires 2 arguments, but only 1 given boost_parameter_template.cpp:24: error: ‘BOOST_PP_IIF_0’ was not declared in this scope boost_parameter_template.cpp:24: error: template argument 1 is invalid boost_parameter_template.cpp:24: error: ‘BOOST_PP_REPEAT_1_BOOST_PP_TUPLE_ELEM_2_0’ does not name a type
2. Have you tried looking at the output of the preprocessor to see what might be happening?
Nope, didn't think of doing that, but I will do next time. ;) The issue lies with my mis-interpretation of the capabilities of BOOST_PARAMETER_CONSTRUCTOR -- I was thinking that it could handle the same semantics for optional parameters the same way that BOOST_PARAMETER_FUNCTION does. I originally had: BOOST_PARAMETER_CONSTRUCTOR( derived, (base<Tag>), tag, (optional (arg1,int,1) (arg2,int,2))) As suggested in the ticket, changing that to: BOOST_PARAMETER_CONSTRUCTOR( derived, (base<Tag>), tag, (optional (arg1,(int)) (arg2,(int)))) Did it, along with moving the optional values to the base constructor's use of the argument pack. Many thanks to Daniel Wallin for the help on the filed ticket. Now I'm ready to move into making cpp-netlib's client and server constructors more friendly and manageable with Boost.Parameter. :D -- Dean Michael Berris deanberris.com
On Tue, Nov 16, 2010 at 4:59 PM, Dean Michael Berris
PS. I am also going to file this as a bug in Boost.Parameter so that it doesn't get lost in the mailing list churn. ;)
Just for completeness, this has been resolved in Trac ticket #4857 [0], thanks to Daniel Wallin for the help! [0] https://svn.boost.org/trac/boost/ticket/4857 -- Dean Michael Berris deanberris.com
participants (2)
-
David Abrahams
-
Dean Michael Berris