To simplify the process of writing custom function objects, the Standard Library provides two classes that serve as base classes of such objects: std::unary_function and std::binary_function. Both are declared in the header
template struct unary_function { typedef Arg argument_type; typedef Res result_type;};template struct binary_function { typedef Arg first_argument_type; typedef Arg2 second_argument_type; typedef Res result_type;};
These classes don’t provide any useful functionality. They are used to ensure that arguments and return values have uniform names. In the following example, a predicate (a function object returning bool) called is_vowel, which takes one argument, inherits from unary_function:
template class is_vowel: public unary_function{public: bool operator ()(T t) const { if ((t=='a')||(t=='e')||(t=='i')||(t=='o')||(t=='u')) return true; return false; }};