boost lambda::bind return type selection
- by psaghelyi
I would like to call a member through lambda::bind. Unfortunately I have got to members with the same name but different return type.
Is there a way to help the lambda::bind to deduce the right return type for a member function call?
#include <vector>
#include <iostream>
#include <algorithm>
#include <boost/bind.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
using namespace std;
using namespace boost;
struct A
{
A (const string & name) : m_name(name) {}
string & name () { return m_name; }
const string & name () const { return m_name; }
string m_name;
};
vector<A> av;
int main ()
{
av.push_back (A ("some name"));
// compiles fine
find_if(av.begin(), av.end(), bind<const string &>(&A::name, _1) == "some name");
// error: call of overloaded 'bind(<unresolved overloaded function type>, const boost::lambda::lambda_functor<boost::lambda::placeholder<1> >&)' is ambiguous
find_if(av.begin(), av.end(), lambda::bind(&A::name, lambda::_1) == "some name");
return 0;
}