Peter Dimov ha escrito:
Joaquín Mª López Muñoz wrote:
Noah Roberts ha escrito:
[...]
So in the end, my problem is thus:
std::find_if(cont.begin(), cont.end(), bind(&deref_val_type::f, _1) == 5);
How is that accomplished with lambda if cont holds smart pointers? So far I haven't found any way...
OK, you can write it with Boost Lambda as follows:
namespace l = boost::lambda;
std::find_if( cont.begin(), cont.end(), l::bind<int>(&*l::_1->*&deref_val_type::f)==5);
bind( &deref_val_type::f, *_1 ) == 5 may work with Lambda.
Almost: the translation of the expression to the lambda world, i.e.
l::bind( &deref_val_type::f, *l::_1 ) == 5
(assuming namespace l = boost::lambda) fails to compile because
it indices the declaration of
boost::tuples::cons