Poster of Linux kernelThe best gift for a Linux geek
Adaptors for pointers to functions

Adaptors for pointers to functions

Section: C Library Functions (3) Updated: 27 Aug 2009
Local index Up
 

NAME

Adaptors for pointers to functions -  

Classes


class pointer_to_binary_function< _Arg1, _Arg2, _Result >
One of the adaptors for function pointers.
class pointer_to_unary_function< _Arg, _Result >
One of the adaptors for function pointers.  

Functions


template<class _Arg1 , class _Arg2 , class _Result > pointer_to_binary_function< _Arg1, _Arg2, _Result > ptr_fun (_Result(*__x)(_Arg1, _Arg2))

template<class _Arg , class _Result > pointer_to_unary_function< _Arg, _Result > ptr_fun (_Result(*__x)(_Arg))
 

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.  

Function Documentation

 

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 525 of file stl_function.h.  

pointer_to_unary_function<_Arg, _Result> std::ptr_fun (_Result(*)(_Arg) __x) [inline]

One of the adaptors for function pointers.

Definition at line 500 of file stl_function.h.  

Author

Generated automatically by Doxygen for libstdc++ from the source code.


 

Index

NAME
Classes
Functions
Detailed Description
Function Documentation
pointer_to_binary_function<_Arg1, _Arg2, _Result> std::ptr_fun (_Result(*)(_Arg1, _Arg2) __x) [inline]
pointer_to_unary_function<_Arg, _Result> std::ptr_fun (_Result(*)(_Arg) __x) [inline]
Author

This document was created by man2html, using the manual pages.
Time: 22:37:11 GMT, April 16, 2011