Keywords: Josuttis, C++, countedptr, counted reference, smart pointer, Code, examples, Beispiele, objektorientiert, Informatik, Nicolai Josuttis, Nicolai M. Josuttis

DEPRECATED: Compose Function Object Adapters

This library is deprecated in favor of the Bind or Lambda libraries, and will be removed in a future release of Boost. The C++ Standard Template Library STL as part of the C++ Standard Library provides several function objects. Unfortunately, it doesn't provide the ability to compose these function objects. For example, it is not possible to combine the result of two unary operations to formulate a criterion such as ``this and that''. But this would be important for building software components out of other components, which leads to the concept of functional composition. So, here are some adapters that close this gap.

In fact, these adapters provide to compose function objects as follows:

Functionality | Boost Name | SGI STL's Name
f(g(value)) | compose_f_gx | compose1
f(g(value),h(value)) | compose_f_gx_hx | compose2
f(g(value1),h(value2)) | compose_f_gx_hy |
f(g(value1,value2)) | compose_f_gxy |
f(g()) | compose_f_g |

As you can see, two of these adapters are part of the SGI STL already. However, we changed the names according to a consistent naming scheme for all adapters.

In addition, this code also defines a type `nullary_function` for function objects that have no argument (as supplement to `unary_function` and `binary_function`) and overloads `ptr_fun` for functions that take no arguments.

The code is provided "as is" without expressed or implied warranty.

compose.hpp:

- as HTML file
- as plain file
  Example for using compose_f_gx
- `as HTML file`
- `as plain file`
Example for using compose_f_gx_hx
- `as HTML file`
- `as plain file`
Example for using compose_f_gx_hy
- `as HTML file`
- `as plain file`
Example for using compose_f_g and `ptr_fun` for functions without arguments
- as HTML file
- as plain file
  To find more details about function objects in general and about these compose functions, see
  The C++ Standard Library - A Tutorial and Reference
  by Nicolai M. Josuttis
  Addison Wesley Longman, 1999
  ISBN 0-201-37926-0
  and the SGI STL documentation

Home Page