Boost logo

Boost Users :

Subject: Re: [Boost-users] [Lambda] Lost in lambda land!
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2010-03-24 04:38:38


On Tue, Mar 23, 2010 at 6:02 PM, Ovanes Markarian <om_boost_at_[hidden]>wrote:

> Hi!
>
> This one works...
>
> #include <boost/lambda/lambda.hpp>
> #include <boost/lambda/bind.hpp>
> #include <boost/lambda/construct.hpp>
> #include <algorithm>
> #include <vector>
>
> struct A
> {
> A(int) {}
> void f()const {}
> };
>
> int main( )
> {
> using namespace boost::lambda;
>
> std::vector< int > v;
> std::for_each( v.begin( ), v.end(), bind(&A::f,
> bind<A>(constructor<A>(), _1)));
> }
>
>
>
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?

- Rob.



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