Keywords: ISO C++, library

Chapter 23. Utilities
Prev | Part III. Extensions | Next

## Chapter 23. Utilities

The `<functional>` header contains many additional functors and helper functions, extending section 20.3. They are implemented in the file stl_function.h:

- `identity_element` for addition and multiplication.

- The functor `identity`, whose `operator()` returns the argument unchanged.

- Composition functors `unary_function` and `binary_function`, and their helpers `compose1` and `compose2`.

- `select1st` and `select2nd`, to strip pairs.

- `project1st` and `project2nd`.

- A set of functors/functions which always return the same result. They are `constant_void_fun`, `constant_binary_fun`, `constant_unary_fun`, `constant0`, `constant1`, and `constant2`.

- The class `subtractive_rng`.

- mem_fun adaptor helpers `mem_fun1` and `mem_fun1_ref` are provided for backwards compatibility.

20.4.1 can use several different allocators; they are described on the main extensions page.

20.4.3 is extended with a special version of `get_temporary_buffer` taking a second argument. The argument is a pointer, which is ignored, but can be used to specify the template type (instead of using explicit function template arguments like the standard version does). That is, in addition to

    get_temporary_buffer<int>(5);

you can also use

    get_temporary_buffer(5, (int*)0);

A class `temporary_buffer` is given in stl_tempbuf.h.

The specialized algorithms of section 20.4.4 are extended with `uninitialized_copy_n`.

Prev | Up | Next
Deprecated | Home | Chapter 24. Algorithms