Adaptors for pointers to functions

pointer_to_unary_function Unary Function Object
pointer_to_binary_function Binary Function Object

pointer_to_unary_function<Arg, Result> ptr_fun (Result (*x)(Arg)) Function
pointer_to_binary_function<Arg1, Arg2, Result> ptr_fun (Result (*x)(Arg1, Arg2)) Function

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

template 
class pointer_to_unary_function : public unary_function {
protected:
    Result (*ptr)(Arg);

public:
    pointer_to_unary_function() {}
    pointer_to_unary_function(Result (*x)(Arg)) : ptr(x) {}
    Result operator()(Arg x) const { return ptr(x); }
};

template 
pointer_to_unary_function ptr_fun(Result (*x)(Arg)) {
    return pointer_to_unary_function(x);
}

template 
class pointer_to_binary_function
: public binary_function {
protected:
    Result (*ptr)(Arg1, Arg2);

public:
    pointer_to_binary_function() {}
    pointer_to_binary_function(Result (*x)(Arg1, Arg2)) : ptr(x) {}
    Result operator()(Arg1 x, Arg2 y) const { return ptr(x, y); }
};

template 
pointer_to_binary_function
    ptr_fun(Result (*x)(Arg1, Arg2)) {
        return pointer_to_binary_function(x);
}
For example, replace_if(v.begin(), v.end(), not1(bind2nd(ptr_fun(strcmp), "C")), "C++") replaces all the "C" with "C++" in sequence v. Compilation systems that have multiple pointer to function types have to provide additional ptr_fun template functions.