|
Boost Users : |
Subject: [Boost-users] Simple Lambda Problem
From: Richard Howard (rhphotography.net_at_[hidden])
Date: 2011-04-07 04:02:58
I am currently trying to get to grips with using Lambda, but I have
hit a problem fairly early on.
Can anyone explain what I am doing wrong.
bool isCar(std::string const & val)
{
return val.find("car") != std::string::npos;
}
int main()
{
std::list<std::string> l;
l.push_back("car");
l.push_back("blue car");
l.push_back("red van");
l.push_back("bike");
l.push_back("blue car");
// ...
l.remove_if(&isCar);
// this works and is how I have done things in the past but I was
hoping to avoid the need for the separate function by using Lambda.
// I have tried the following
l.remove_if(boost::lambda::var(boost::lambda::bind(&std::string::find,
boost::lambda::_1, "car")) != std::string::npos);
// I am not sure why this does not work, can anyone point me in the
right direction?
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net