Felics Felics - 10 months ago 58
C++ Question

std unary functions for common operations

Is there a reason to not have unary versions for the binary functions from functional?

I know is simple to create unary versions by using

, but the code looks ugly:

std::find_if(std::begin(v), std::end(v), std::bind(std::less_equal<int>(), std::placeholders::_1, 42));

I think it would be much nicer to have something like:

std::find_if(std::begin(v), std::end(v), std::less_equal<int>(42));


IMHO since C++11/14, lambdas make this sort of predicates superfluous?

find_if(begin(v), end(v), [](auto x){ return x <= 42; });