
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); Boost.Bind is smarter here, since Boost Lambda needs assistance in: 1. Determining the return type of deref_val_type::f (hence the <int> in l::bind<int>.) 2. Dereferencing the shared_ptr, hence the use of &*l::_1 to get a plain pointer from the shared_ptr, combined with ->* to call deref_val_type::f Others might find terser ways to express this with Boost Lambda, but looks like Boost.Bind is a clear winner here. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo