Function objects are objects whose class defines member function operator(). This member function allows the object to be used with the same syntax as a regular function call. Several standard algorithms and adaptors are designed to be used with function objects.
It is defined with the same behavior as:
| 1 2 3 4 5 6 7 8 9 10 11 |
|
Template parameters
- Arg, Arg1, Arg2
- Types of the function's arguments.
- Result
- Function's return type.
Parameters
[/dl]
Return value
A function object equivalent to f.pointer_to_unary_function and pointer_to_binary_function are function object types, derived respectively from unary_function and binary_function.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Possible output:
sum = 150 |
See also
| mem_fun | Convert member function to function object (pointer version) (function template) |
| pointer_to_unary_function | Generate unary function object class from pointer (class template) |
| pointer_to_binary_function | Generate binary function object class from pointer (class template) |
| unary_function | Unary function object base class (class template) |
