libstdc++

The advantage of function objects over pointers to functions is that the objects in the standard library declare nested typedefs describing their argument and result types with uniform names (e.g., result_type
from the base classes unary_function
and binary_function
). Sometimes those typedefs are required, not just optional.
Adaptors are provided to turn pointers to unary (singleargument) and binary (doubleargument) functions into function objects. The longwinded functor pointer_to_unary_function
is constructed with a function pointer f
, and its operator()
called with argument x
returns f(x)
. The functor pointer_to_binary_function
does the same thing, but with a doubleargument f
and operator()
.
The function ptr_fun
takes a pointertofunction f
and constructs an instance of the appropriate functor.
pointer_to_unary_function<_Arg, _Result> std::ptr_fun  (  _Result(*)(_Arg)  __x  )  [inline] 
One of the adaptors for function pointers.
Definition at line 443 of file stl_function.h.
pointer_to_binary_function<_Arg1, _Arg2, _Result> std::ptr_fun  (  _Result(*)(_Arg1, _Arg2)  __x  )  [inline] 
One of the adaptors for function pointers.
Definition at line 469 of file stl_function.h.