Boost logo

Boost :

Subject: [boost] [parameter] BOOST_PARAMETER_CONSTRUCTOR bug
From: James Hirschorn (james.hirschorn_at_[hidden])
Date: 2013-05-21 15:19:36


I've already submitted a bug report, but I'm also posting it here in case
anyone has more info.

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

The following variation on the example from the boost::parameter tutorial,
where the required parameter is changed to optional, fails to compile.
myclass_impl is being passed an empty argument list.

#include <iostream>

#include <boost/parameter.hpp>

BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)

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

struct myclass : myclass_impl
{
    BOOST_PARAMETER_CONSTRUCTOR(
        myclass, (myclass_impl), tag
            , (optional (name, *) (index, *)
                )
    ) // no semicolon
};

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


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