Annex D (normative) Compatibility features [depr]

D.8 Function objects [depr.function.objects]

D.8.2 Function adaptors [depr.adaptors]

D.8.2.1 Adaptors for pointers to functions [depr.function.pointer.adaptors]

To allow pointers to (unary and binary) functions to work with function adaptors the library provides:

template <class Arg, class Result> class pointer_to_unary_function : public unary_function<Arg, Result> { public: explicit pointer_to_unary_function(Result (*f)(Arg)); Result operator()(Arg x) const; };

operator() returns f(x).

template <class Arg, class Result> pointer_to_unary_function<Arg, Result> ptr_fun(Result (*f)(Arg));

Returns: pointer_to_unary_function<Arg, Result>(f).

template <class Arg1, class Arg2, class Result> class pointer_to_binary_function : public binary_function<Arg1,Arg2,Result> { public: explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)); Result operator()(Arg1 x, Arg2 y) const; };

operator() returns f(x,y).

template <class Arg1, class Arg2, class Result> pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1, Arg2));

Returns: pointer_to_binary_function<Arg1,Arg2,Result>(f).

Example:

int compare(const char*, const char*);
replace_if(v.begin(), v.end(),
  not1(bind2nd(ptr_fun(compare), "abc")), "def");

replaces each abc with def in sequence v.  — end example ]