cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : Miscellaneous : functional
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Miscellaneous
complex
exception
functional
iterator
limits
locale
memory
new
numeric
stdexcept
typeinfo
utility
valarray
functional
binary_function
unary_function
operator classes:
· divides
· equal_to
· greater
· greater_equal
· less
· less_equal
· logical_and
· logical_not
· logical_or
· minus
· modulus
· multiplies
· negate
· not_equal_to
· plus
adaptor functions:
· bind1st
· bind2nd
· mem_fun
· mem_fun_ref
· not1
· not2
· ptr_fun
types:
· binary_negate
· binder1st
· binder2nd
· const_mem_fun1_ref_t
· const_mem_fun1_t
· const_mem_fun_ref_t
· const_mem_fun_t
· mem_fun1_ref_t
· mem_fun1_t
· mem_fun_ref_t
· mem_fun_t
· pointer_to_binary_fu...
· pointer_to_unary_fun...
· unary_negate

-

functional header

Function objects

Function objects are objects specifically designed to be used with a syntax similar to that of functions. In C++, this is achieved by defining member function operator() in their class, like for example:

struct myclass {
  int operator()(int a) {return a;}
} myobject;
int x = myobject (0);           // function-like syntax with object myobject 

They are especially useful as predicates or comparison functions to be used with standard algorithms.
The standard library provides standard definitions for several function objects and some ways to modify and adapt their behavior in header <functional>:

Base classes:

unary_function Unary function object base class (class template)
binary_function Binary function object base class (class template)

Operator classes

Arithmetic operations:

plus Addition function object class (class template)
minus Subtraction function object class (class template)
multiplies Multiplication function object class (class template)
divides Division function object class (class template)
modulus Modulus function object class (class template)
negate Negative function object class (class template)

Comparison operations:

equal_to Function object class for equality comparison (class template)
not_equal_to Function object class for non-equality comparison (class template)
greater Function object class for greater-than inequality comparison (class template)
less Function object class for less-than inequality comparison (class template)
greater_equal Function object class for greater-than-or-equal-to comparison (class template)
less_equal Function object class for less-than-or-equal-to comparison (class template)

Logical operations:

logical_and Logical AND function object class (class template)
logical_or Logical OR function object class (class template)
logical_not Logical NOT function object class (class template)

Adaptor and conversion functions

Negators
not1 Return negation of unary function object (function template)
not2 Return negation of binary function object (function template)

Parameter binders

bind1st Return function object with first parameter binded (function template)
bind2nd Return function object with second parameter binded (function template)

Conversors

ptr_fun Convert function pointer to function object (function template)
mem_fun Convert member function to function object (pointer version) (function template)
mem_fun_ref Convert member function to function object (reference version) (class template)

Instrumental types

unary_negate Generate negation of unary function object class (class template)
binary_negate Generate negation of binary function object class (class template)
binder1st Generate function object class with 1st parameter binded (class template)
binder2nd Generate function object class with 2nd parameter binded (class 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)
mem_fun_t Generate function object class from parameterless member (pointer version) (class template)
mem_fun1_t Generate function object class from single-parameter member (pointer version) (class template)
const_mem_fun_t Generate function object class from const parameterless member (pointer version) (class template)
const_mem_fun1_t Generate function object class from single-parameter const member (pointer version) (class template)
mem_fun_ref_t Generate function object class from parameterless member (reference version) (class template)
mem_fun1_ref_t Generate function object class from single-parameter member (reference version) (class template)
const_mem_fun_ref_t Generate function object class from const parameterless member (reference version) (class template)
const_mem_fun1_ref_t Generate function object class from single-parameter const member (reference version) (class template)

Home page | Privacy policy
© cplusplus.com, 2000-2009 - All rights reserved - v2.2
Spotted an error? contact us