David Abrahams wrote:
At Wed, 25 Aug 2010 22:48:57 -0700,
Ryan McConnehey wrote:
  
I'm new to the parameter library and started with a simple example to 
get my feet wet.  The first problem I'm having is with type 
restriction.  The "name" variable is being restricted to a boolean 
type.  This doesn't seem to be enforced since I can pass this variable a 
value of 15 and get this same value out.  Currently my output has "name 
= 15" and I expected the output to be "name = 1".  Did I not correctly 
enforce the type?
    

Looks like a bug to me.  Daniel?

  
The second problem is with the default value of my variable.  I thought 
if the variable wasn't used then the third parameter, in the 
declaration, is used for instantiation of that variable.  I thought that 
meant I could do this "m_name(args[_name])".  The compiler gives an 
error saying the operator[] can't deduce the arguments.  What did I not 
do that would allow this behavior.
    

Ditto, looks like a bug.  If we don't already have tests for these
cases, we should.

  
Thank you for your time in helping me out.

Ryan


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
    {
      std::cout << "name = " << m_name << std::endl;
    }

private:
  int         m_name;
};

struct myclass : public myclass_impl
{
    BOOST_PARAMETER_CONSTRUCTOR(
        myclass, (myclass_impl), tag
      , (optional
          (name, (bool), bool(false)))) // no semicolon
};

int main(int argc, char* argv[])
{
  myclass x(_name = 15);

return 0;
}
    

Thanks for the update.  If this is indeed a bug I look forward to seeing it fixed.

Ryan