
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<deref_val_type, boost::tuples::null_type>::head which is not instantiable deref_val_type is abstract. The closest I can get in BLL to your formulation is: l::bind( &deref_val_type::f, &*l::_1 ) == 5 which works as expected. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo