Boost logo

Boost :

Subject: Re: [boost] [parameter] BOOST_PARAMETER_CONSTRUCTOR bug
From: James Hirschorn (james.hirschorn_at_[hidden])
Date: 2013-06-07 15:41:45


The following variation does not seem to work according to the documentation.
Can someone explain this?

--------------------

#include <iostream>

#include <boost/parameter.hpp>

BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
BOOST_PARAMETER_NAME(ratio)

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

struct myclass : myclass_impl
{
    BOOST_PARAMETER_CONSTRUCTOR(
        myclass, (myclass_impl), tag
            , (optional (name, (char const*)) (index, (int))
                )
                (deduced
                    (optional (ratio, *))
                )
    )

};

int main(int argc, char * argv[])
{
    myclass C(_name="hello", _index=1);
    myclass D(4.6);
}

----------------

In the construction of D, 4.6 is not deduced as having the keyword ratio,
and the program fails to compile. The deduced clause seems to be ignored.
Is this not a bug?

--
View this message in context: http://boost.2283326.n4.nabble.com/parameter-BOOST-PARAMETER-CONSTRUCTOR-bug-tp4647592p4648390.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

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