![]() |
Home | Libraries | People | FAQ | More |
boost::functionN — A set of generalized function pointers that can be used for callbacks or wrapping function objects.
// In header: <boost/function.hpp> template<typename R, typename T1, typename T2, ..., typename TN> class functionN : public function_base { public: // types typedef ; typedef ; // If N == 1 typedef ; // If N == 2 typedef ; // If N == 2 typedef ; typedef ; . . . typedef ; // static constants = ; // member classes/structs/unions // Lambda library support template<typename Args> struct sig { // types typedef ; }; // construct/copy/destruct (); (functionN&); (functionN&&); template<typename F> (); template<typename F, typename Allocator> (, ); functionN& (functionN&); functionN& (functionN&&); ~(); // modifiers (functionN&); (); // capacity () ; () ; () ; // target access template<typename Functor> (); template<typename Functor> () ; template<typename Functor> () ; () ; // invocation (, , ..., ) ; }; // specialized algorithms template<typename T1, typename T2, ..., typename TN> (functionN<, functionN<); // comparison operators template<typename T1, typename T2, ..., typename TN, typename Functor> (functionN<, ); template<typename T1, typename T2, ..., typename TN, typename Functor> (, functionN<); template<typename T1, typename T2, ..., typename TN, typename Functor> (functionN<, reference_wrapper<); template<typename T1, typename T2, ..., typename TN, typename Functor> (reference_wrapper<, functionN<); template<typename T1, typename T2, ..., typename TN, typename U1, typename U2, ..., typename UN> (functionN<, functionN<); template<typename T1, typename T2, ..., typename TN, typename Functor> (functionN<, ); template<typename T1, typename T2, ..., typename TN, typename Functor> (, functionN<); template<typename T1, typename T2, ..., typename TN, typename Functor> (functionN<, reference_wrapper<); template<typename T1, typename T2, ..., typename TN, typename Functor> (reference_wrapper<, functionN<); template<typename T1, typename T2, ..., typename TN, typename U1, typename U2, ..., typename UN> (functionN<, functionN<);
Class template functionN is
actually a family of related classes function0, function1, etc., up to some
implementation-defined maximum. In this context, N
refers to the number of parameters.
functionN
public
construct/copy/destruct();
Postconditions: |
this->empty() |
Throws: |
Will not throw. |
(functionN& f);
Postconditions: |
Contains a copy of the f 's target, if it has one, or is empty if f.empty() . |
Throws: |
Will not throw unless copying the target of f throws. |
(functionN&& f);
Requires: |
C++11 compatible compiler. |
Postconditions: |
Moves the value from f to *this . If the argument has its function object allocated on the heap, its buffer will be assigned to *this leaving argument empty. |
Throws: |
Will not throw unless argument has its function object allocated not on the heap and copying the target of f throws. |
template<typename F> ( f);
Requires: |
F is a function object Callable from this . |
Postconditions: |
*this targets a copy of f if f is nonempty, or this->empty() if f is empty. |
template<typename F, typename Allocator> ( f, alloc);
Requires: |
F is a function object Callable from this , Allocator is an allocator. The copy constructor and destructor of Allocator shall not throw. |
Postconditions: |
*this targets a copy of f if f is nonempty, or this->empty() if f is empty. |
Effects: |
If memory allocation is required, the given allocator (or a copy of it) will be used to allocate that memory. |
functionN& (functionN& f);
functionN& (functionN&& f);
Requires: |
C++11 compatible compiler. |
Postconditions: |
Moves the value from f to *this . If the argument has its function object allocated on the heap, its buffer will be assigned to *this leaving argument empty. |
Throws: |
Will not throw unless argument has its function object allocated not on the heap and copying the target of f throws. |
~();
Effects: |
If !this->empty() , destroys the target of this. |
functionN
target accesstemplate<typename Functor> (); template<typename Functor> () ;
Returns: |
If this stores a target of type
Functor , returns the address of the
target. Otherwise, returns the NULL
pointer. |
Throws: |
Will not throw. |
template<typename Functor> ( f) ;
Returns: |
true if this->target<Functor>() is non-NULL and function_equal(*(this->target<Functor>()), f)
|
() ;
Returns: |
typeid of the target function object, or typeid(void) if this->empty() . |
Throws: |
Will not throw. |
functionN
invocation( a1, a2, ..., aN) ;
Effects: |
f(a1, a2, ..., aN) , where f is the target of *this . |
Returns: |
if R is void , nothing is returned; otherwise, the return value of the call to f is returned. |
Throws: |
bad_function_call if this->empty() . Otherwise, may through any exception thrown by the target function f . |
functionN
comparison operatorstemplate<typename T1, typename T2, ..., typename TN, typename Functor> (functionN< f, g); template<typename T1, typename T2, ..., typename TN, typename Functor> ( g, functionN< f); template<typename T1, typename T2, ..., typename TN, typename Functor> (functionN< f, reference_wrapper< g); template<typename T1, typename T2, ..., typename TN, typename Functor> (reference_wrapper< g, functionN< f); template<typename T1, typename T2, ..., typename TN, typename U1, typename U2, ..., typename UN> (functionN< f1, functionN< f2);
Returns: |
True when f stores an object of
type Functor and one of the following conditions applies:
|
Notes: |
functionN
objects are not
EqualityComparable. |
Rationale: |
The safe_bool conversion
opens a loophole whereby two functionN
instances can be compared via == , although this
is not feasible to implement. The undefined void
operator== closes the loophole and ensures a
compile-time or link-time error. |
template<typename T1, typename T2, ..., typename TN, typename Functor> (functionN< f, g); template<typename T1, typename T2, ..., typename TN, typename Functor> ( g, functionN< f); template<typename T1, typename T2, ..., typename TN, typename Functor> (functionN< f, reference_wrapper< g); template<typename T1, typename T2, ..., typename TN, typename Functor> (reference_wrapper< g, functionN< f); template<typename T1, typename T2, ..., typename TN, typename U1, typename U2, ..., typename UN> (functionN< f1, functionN< f2);
Returns: |
True when f does not store an
object of type Functor or it stores an object of
type Functor and one of the following conditions
applies:
|
Notes: |
functionN
objects are not
EqualityComparable. |
Rationale: |
The safe_bool conversion
opens a loophole whereby two functionN
instances can be compared via != , although this
is not feasible to implement. The undefined void
operator!= closes the loophole and ensures a
compile-time or link-time error. |