Let's say I have this type:
typedef boost::function<bool (Foo)> filter_function;
And a vector of those "filter functions":
std::vector<filter_function> filters;
If want to call all the filter functions, one by one, and only the the last call returned true.
Inspired by a previous question, I ended up writing:
bool Bar::filterFoo(Foo& foo)
{
return (std::find_if(filters.begin(), filters.end(), boost::lambda::bind(boost::lambda::_1, foo)) == filters.end());
}
But this is wrong: the return value of the lambda should be negated.
I tried to use std::not1
, std::not2
at different places but couldn't find any variation that doesn't end up in a (pretty verbose) compilation error.
What is the correct way to do this ?