boost::bind overloads several operators for its placeholders:
For convenience, the function objects produced by
bindoverload the logical not operator!and the relational and logical operators==,!=,<,<=,>,>=,&&,||.
For example, this allows me to pass _1 == desired_value as a predicate to STL algorithms.
Unfortunately, std::bind does not seem to overload these operators 🙁
-
Why is that?
-
What is a good workaround to simulate
_1 == desired_valuewithstd::bind?
IIRC, Boost.Bind only overloads those operators for the placeholders because the original Boost Lambda Library, which Boost.Bind is an improvement of, did (Boost.Bind is obsolete thanks to Boost.Phoenix, btw).
std::bind‘s placeholders are only intended for exactly that purpose, as placeholders for arguments tostd::bind.As a workaround, use polymorphic functors:
Live example on Ideone.