Boost logo

Boost :

Subject: Re: [boost] [parameter] BOOST_PARAMETER_CONSTRUCTOR bug
From: Nathan Crookston (nathan.crookston_at_[hidden])
Date: 2013-05-21 16:50:51


James Hirschorn wrote:

> struct myclass_impl
> {
> template <class ArgumentPack>
> myclass_impl(ArgumentPack const& args)
> {
> std::cout << "name = " << args[_name]
> << "; index = " << args[_index]
> << std::endl;
> }
> };
>

I believe when you have an optional constructor parameter, you must access
it with the default value supplied:

struct myclass_impl
{
    template <class ArgumentPack>
    myclass_impl(ArgumentPack const& args)
    {
        std::cout << "name = " << args[_name | ""]
                  << "; index = " << args[_index | 0]
                  << std::endl;
    }
};

(Note the bitwise or "|"). This is a little different than for named
function parameters, it seems.

HTH,
Nate


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