Why do some STL algorithms provide an additional '_if'
function instead of overloading it?
// example:
find(beg, end, val);
find_if(beg, end, pred);
Couldn't they just have overloaded those algorithms instead of making additional _if
functions?
Those algorithms provide a named version rather than an overloaded one because both versions of the algorithm take the same number of arguments. Overloading ambiguities would therefore be possible.
To avoid any possible ambiguities, the library provides separate named versions for those algorithms, find_if
is one of those.