J
Juha Nieminen
Basically any STL algorithm which requires a predicate as parameter
can be given either a function object or a regular function as that
parameter. For example, you can give a function object or a regular
function pointer as the third parameter to std::remove_if(), and it
will work ok.
If you want to *negate* the predicate, you can do it with std::not1().
However, for some reason std::not1() can only be called with a function
object, not a function pointer. If you want to use it with a regular
function, you have to do it like std::not1(std:tr_fun(theFunction)).
But why? Why couldn't std::not1() accept a regular function as parameter?
can be given either a function object or a regular function as that
parameter. For example, you can give a function object or a regular
function pointer as the third parameter to std::remove_if(), and it
will work ok.
If you want to *negate* the predicate, you can do it with std::not1().
However, for some reason std::not1() can only be called with a function
object, not a function pointer. If you want to use it with a regular
function, you have to do it like std::not1(std:tr_fun(theFunction)).
But why? Why couldn't std::not1() accept a regular function as parameter?