Dave Abrahams wrote:
Would you mind posting minimal test cases for these issues to Trac
I haven't used boost test before, so this might not be correct. Also,
I'm not sure the usefulness of the test that doesn't specify an optional
value. The desired method of extracting the "_name" parameter doesn't
compile. Once it does the test will always work.
Is "Trac" something specific or did you mean "track"? Is the below not
what is needed?
Ryan
#include
BOOST_PARAMETER_NAME(name)
struct myclass_impl
{
template <class ArgumentPack>
myclass_impl(ArgumentPack const& args)
: m_name(args[_name | false])
//: m_name(args[_name]) //gives a compile error
{}
int getValue(void) const { return m_name; }
private:
int m_name;
};
struct myclass : public myclass_impl
{
BOOST_PARAMETER_CONSTRUCTOR(
myclass, (myclass_impl), tag
, (optional
(name, (bool), bool(false)))) // no semicolon
};
BOOST_AUTO_TEST_CASE( parameter_bool_test )
{
myclass a0(_name = 15);
BOOST_CHECK_EQUAL( a0.getValue(), 1 );
myclass a1;
BOOST_CHECK_EQUAL( a1.getValue(), 0 );
}