Boost logo

Boost Users :

Subject: Re: [Boost-users] [Lambda] Lost in lambda land!
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2010-03-23 14:02:01


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)));
}

Regards,
Ovanes

On Tue, Mar 23, 2010 at 6:41 PM, Robert Jones <robertgbjones_at_[hidden]>wrote:

> Hi Folks,
>
> Can anyone tell me why this is wrong? My intention is to call A::f() for
> each A constructed
> on-the-fly from the elements of v.
>
> Thanks, Rob.
>
> #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( );
> };
>
> int main( )
> {
> using namespace boost::lambda;
>
> std::vector< int > v;
> std::for_each( v.begin( ), v.end( ), bind( & A::f, bind(
> constructor<A>(), _1 ) ) );
> }
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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