Boost logo

Boost Users :

Subject: Re: [Boost-users] [Lambda] Lost in lambda land!
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2010-03-24 05:19:43


On Wed, Mar 24, 2010 at 9:38 AM, Robert Jones <robertgbjones_at_[hidden]>wrote:

>
> It does indeed, making method f() const fixes it, but I still can't quite
> see why. Without the
> constness of f() the guts of the error says this,
>
> /usr/include/boost/lambda/detail/actions.hpp:87: error: no matching
> function for call to ‘boost::lambda::function_adaptor<void
> (A::*)()>::apply(void (A::* const&)(), const A&)’
>
> from which it seems that the constructed required signature includes a
> const A&. Why is this?
>

Because A() is an rvalue, a temporary which cannot be assigned to a
non-const reference.

What you propose is pretty equal to the following ill-formed construct:

void do_smth(A& a)
{
  // do smth.
}

do_smth(A(7));

So the best boost::bind overload which compiler finds is that which accepts
A const& => only const members are allowed to be accessed.

Regards,
Ovanes



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net