Adaptors for pointers to functions
Utilities » Function Objects
Collaboration diagram for Adaptors for pointers to functions:

## Classes

class | std::pointer_to_binary_function< _Arg1, _Arg2, _Result >
class | std::pointer_to_unary_function< _Arg, _Result >

## Functions

template<typename _Arg, typename _Result>
pointer_to_unary_function< _Arg, _Result > | std::ptr_fun (_Result(*__x)(_Arg))
template<typename _Arg1, typename _Arg2, typename _Result>
pointer_to_binary_function< _Arg1, _Arg2, _Result > | std::ptr_fun (_Result(*__x)(_Arg1, _Arg2))

## Detailed Description

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 (single-argument) and binary (double-argument) functions into function objects. The long-winded 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 double-argument f and operator().

The function ptr_fun takes a pointer-to-function f and constructs an instance of the appropriate functor.

Deprecated
  Deprecated in C++11, no longer in the standard since C++17.

## Function Documentation

## ptr_fun() [1/2]

template<typename _Arg, typename _Result>

pointer_to_unary_function< _Arg, _Result > std::ptr_fun | ( | _Result(* | __x )(_Arg) | ) |

inline

One of the adaptors for function pointers.

Definition at line 1119 of file stl_function.h.

## ptr_fun() [2/2]

template<typename _Arg1, typename _Arg2, typename _Result>

pointer_to_binary_function< _Arg1, _Arg2, _Result > std::ptr_fun | ( | _Result(* | __x )(_Arg1, _Arg2) | ) |

inline

One of the adaptors for function pointers.

Definition at line 1145 of file stl_function.h.