Boost logo

Boost :

Subject: Re: [boost] [Boost-users] [parameter] Boost.Parameter Constructors in Template Classes
From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2010-11-16 05:12:39


On Tue, Nov 16, 2010 at 6:00 PM, David Abrahams <dave_at_[hidden]> wrote:
> 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#parameter-enabled-constructors)
>> 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

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk