[parameter] Can't piecewise compose arguments.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[parameter] Can't piecewise compose arguments.

Rene Rivera
I'm using the Parameters lib in class constructors. In which case I end
up having to piecewise build argument lists as classes call the
superclass ctors. But as it turns out it doesn't compile, for example:

#include <boost/parameter.hpp>

namespace Param {
   BOOST_PARAMETER_KEYWORD(Tag,a0)
   BOOST_PARAMETER_KEYWORD(Tag,a1)
   BOOST_PARAMETER_KEYWORD(Tag,a2)
}

struct A
{
   template <typename ArgPack> A(ArgPack const & args)
   {
     int i = args[Param::a0];
     int j = args[Param::a1];
   }
};

struct B : A
{
   template <typename ArgPack> B(ArgPack const & args)
     : A((args, Param::a0 = 1))
   {
   }
};

void param_test()
{
   A a((Param::a0 = 1, Param::a1 = 13, Param::a2 = 6));
   B b0((Param::a1 = 13));
   B b1((Param::a1 = 13, Param::a2 = 6)); //!!
}

The "b1" declaration doesn't compile, although it seems like it should.
The reason is simple enough, the operator,() in arg_list isn't const
which causes a no function match error. The fix is obvious:

===boost/parameter/aux_/arg_lit.hpp===
@@ -311,5 +311,5 @@
        template <class KW, class T2>
        arg_list<tagged_argument<KW, T2>, self>
<      operator,(tagged_argument<KW,T2> x)
->     operator,(tagged_argument<KW,T2> x) const
        {
            return arg_list<tagged_argument<KW,T2>, self>(x, *this);
======

Sorry if I don't have reasonable diff, this is from Perforce :-(

Is there a rational for the operator,() not being const?


--
-- Grafik - Don't Assume Anything
-- Redshift Software, Inc. - http://redshift-software.com
-- rrivera/acm.org - grafik/redshift-software.com
-- 102708583/icq - grafikrobot/aim - grafikrobot/yahoo
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [parameter] Can't piecewise compose arguments.

David Abrahams
Rene Rivera <[hidden email]> writes:

> Is there a rational for the operator,() not being const?

I don't think so.  Please feel free to make the patch, but please fix
any ensuing test failures! :)


--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost