Boost logo

Boost Users :

Subject: Re: [Boost-users] [parameter] Weird behavior with bools
From: Ryan McConnehey (mccorywork_at_[hidden])
Date: 2010-08-29 20:54:24

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?


#include <boost/test/unit_test.hpp>

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; }
  int m_name;
struct myclass : public myclass_impl
        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 );

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at