Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2006-01-30 18:49:39

Cromwell Enage <sponage_at_[hidden]> writes:

> --- David Abrahams wrote:
>> I take it back; I'm pretty sure this has nothing to
>> do with forwarding. On what line of *your code*
>> does that error appear?
> The error appears on the line with the // error
> comment.

The actual error, and not just some line of the instantiation
backtrace? That makes no sense to me, because the functions generated
by BOOST_PARAMETER_FUN take their arguments by const&. The error
should appear wherever you try to bind a non-const reference to the
resulting const lvalue. Aha:

    typedef typename boost::remove_const<
                typename boost::parameter::binding<
                  , tag::rng_engine


    RNGEngine rng_engine = p[example::rng_engine];

According to,
binding<Params,Tag>::type is always a reference type. Since

   remove_const<T&> is T&

when T is const (as it is in this case), you get a reference to
const. Thus RNGEngine is

  boost::mt19937 const&

and the error should come here:

    typedef boost::variate_generator<RNGEngine,RNGDist> RNG;
    RNG rng(rng_engine, RNGDist(p[min], p[max]));

where variate_generator takes its first constructor argument by
mutable reference.

If my analysis is wrong, please explain how it is so.

Dave Abrahams
Boost Consulting

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