Couldn\'t find_if
just be an overload of find
? That\'s how std::binary_search
and friends do it...
You can certainly implement find
in terms of find_if
using some sort of equality predicate.
I would guess that the real reason is that you can implement find
fairly easily and provide performant specialised implementations for typical encountered types; if you are using find_if
, the predicate you pass in can be arbitrarily complex, which gives the library implementer less scope of optimisation.
Also, C++ has the philosphy of "you don't pay for what you don't use" and you'd normally expect that you don't want to pay for a predicate evaluation if a simple comparison will do.