<functional> (TR1)
Defines several templates that help construct function objects, which are objects of a type that defines operator(). A function object can be a function pointer, but more typically, the object is used to store additional information that can be accessed during a function call.
#include <functional>
Remarks
The following features are added by using TR1:
A call signature is the name of a return type followed by a parenthesized comma-separated list of zero or more argument types.
A call wrapper is an object of a call wrapper type.
A call wrapper type is a type that holds a callable object and supports a call operation that forwards to that object.
A callable object is an object of a callable type.
A callable type is a pointer to function, a pointer to member function, a pointer to member data, or a class type whose objects can appear immediately to the left of a function call operator.
A target object is the callable object held by a call wrapper object.
The pseudo-function INVOKE(f, t1, t2, ..., tN) means one of the following things:
(t1.*f)(t2, ..., tN) when f is a pointer to member function of class T and t1 is an object of type T or a reference to an object of type T or a reference to an object of a type derived from T.
((*t1).*f)(t2, ..., tN) when f is a pointer to member function of class T and t1 is not one of the types described in the previous item.
t1.*f when f is a pointer to member data of class T and t1 is an object of type T or a reference to an object of type T or a reference to an object of a type derived from T.
(*t1).*f when f is a pointer to member data of class class T and t1 is not one of the types described in the previous item.
f(t1, t2, ..., tN) in all other cases.
The pseudo-function INVOKE(f, t1, t2, ..., tN, R) means INVOKE(f, t1, t2, ..., tN) implicitly converted to R.
If a call wrapper has a weak result type, the type of its member type result_type is based on the type T of the target object of the wrapper, as follows:
If T is a pointer to function, result_type is a synonym for the return type of T.
If T is a pointer to member function, result_type is a synonym for the return type of T.
If T is a pointer to data member, result_type is a synonym for the declared type of the data member.
If T is a class type that has a member type result_type, then result_type is a synonym for T::result_type.
Otherwise, there is no member result_type.
Every call wrapper has a copy constructor. A simple call wrapper is a call wrapper that has an assignment operator and whose copy constructor and assignment operator do not throw exceptions. A forwarding call wrapper is a call wrapper that can be called by using an argument list t1, t2, ..., tN, where each ti is an lvalue.
The call wrappers defined in this header support function call operators that have arguments of types T1, T2, ..., TN, where 0 <= N <= NMAX. In this implementation, the value of NMAX is 10.
Declarations
Class |
Description |
---|---|
Reports a bad function call. |
|
Wrapper for a callable object. |
|
Computes a hash code for a value. |
|
Tests whether type is generated by calling bind. |
|
Tests whether type is a placeholder. |
|
Wraps a reference. |
|
The return type of a wrapped callable object. |
Object |
Description |
---|---|
Placeholders for replaceable arguments. |
Template Functions
Operator |
Description |
---|---|
Disallows equality comparison of callable objects. |
|
Disallows inequality comparison of callable objects. |
Function |
Description |
---|---|
Binds arguments to a callable object. |
|
Constructs a const reference_wrapper from an argument. |
|
Generates a simple call wrapper. |
|
Constructs a reference_wrapper from an argument. |
|
Swaps two function objects. |