Home | Libraries | People | FAQ | More |
The header
Type | Contents | Description |
---|---|---|
The type of the function or function object itself (i.e., T). | ||
The type that should be used to pass the function or function object as a parameter. | ||
The type returned by the function or function object. | ||
The type of the argument to the function or function object. | ||
The type of the function or function object itself (i.e., T). | ||
The type that should be used to pass the function or function object as a parameter. | ||
The type returned by the function or function object. | ||
The type of the first argument to the function or function object. | ||
The type of the second argument to the function or function object. |
The most common usage of these templates is in function object adapters, thus allowing them to adapt plain functions as well as function objects. You can do this by wherever you would normally write, for example,
typename Operation::argument_type
simply writing
typename boost::unary_traits<Operation>::argument_type
instead.
In addition to the standard result and argument typedefs, these traits templates define two additional types.
This is the type of the function or function object, and can be used in declarations such as
template <class Predicate> class unary_negate : // ... { // ... private: typename unary_traits<Predicate>::function_type pred; };
If this typedef were not provided, it would not be possible to
declare pred in a way that would allow
This is a type suitable for passing the function or function object as a parameter to another function. For example,
template <class Predicate> class unary_negate : // ... { public: explicit unary_negate(typename unary_traits<Predicate>::param_type x) : pred(x) {} // ... };
Function objects are passed by reference to const; function pointers are passed by value.
This library uses these traits within all function object adapters,
theoretically rendering
These traits templates will also not work with compilers that fail
to support partial specialisation of templates. With these compilers,
the traits templates can only be instantiated with adaptable function
objects, thus requiring
Copyright © 2000 Cadenza New Zealand Ltd. Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.
Revised 28 June 2000