|
Boost Users : |
Subject: [Boost-users] [Bind][Lambda] Processing containers of pointers
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2010-03-24 06:57:35
Hi All
I believe boost.bind has the capability to look through pointers and smart
pointers to
transparently process the pointed-to objects. Does boost.lambda.bind also
have this
capability?
I.e., this bit of code (and I am specifically using boost 1.37 for this btw)
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/lambda/construct.hpp>
#include <boost/shared_ptr.hpp>
#include <algorithm>
#include <vector>
struct A
{
A( int );
void f( );
};
int main( )
{
using namespace boost::lambda;
std::vector< A * > pv;
std::vector< boost::shared_ptr< A > > sv;
std::for_each( pv.begin( ), pv.end( ), bind( &A::f, _1 ) );
std::for_each( sv.begin( ), sv.end( ), bind( &A::f, _1 ) ); // error
here.
}
Thanks,
- 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