On 11/29/06, "JOAQUIN LOPEZ MU?Z" wrote:
First, thank you for your response.
std::cerr << "Value: " <<
(l::bind(&test_b::f, l::_1))(boost::ref(td)) << "\n";
Well, I tried putting ref on the other side but this works...my way didn't.
Now I would need to find how to use this solution for my original
problem when td is actually a shared_ptr to an abstract base:
boost::shared_ptr td = boost::shared_ptr(new test_d);
This does not work:
l::bind(l::bind(&test_b::f, l::_1), boost::ref(*l::_1))(td)
Unlike boost::bind, lambda::bind doesn't work like this:
l::bind(&test_b::f, l::_1)(td)
This does but can't be used in an algorithm on a container holding
smart pointers:
l::bind(&test_b::f, l::_1)(boost::ref(*td))
Interestingly, boost::bind has an operator == that will allow me to
compare the result of f() to a value just fine...I thought I needed
lambda for this. Boost::bind doesn't suffer from an inability to work
directly with smart pointers and doesn't require special magic to use
them vs. raw vs. non-ptr. So my original problem is solved by tossing
lambda out the airlock but it might be worthwhile to find a way to
accomplish a smart pointer member call with lambda for the future.
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...