On Wed, Mar 24, 2010 at 9:38 AM, Robert Jones
<robertgbjones@gmail.com> 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