The so-called algorithms in the standard library distinguish C++ from other programming languages. Every major programming language has a suite of container types, but in the traditional object-oriented approach, each container class defines the operations that it permits, e.g., sorting, searching, and modifying. C++ turns object-oriented programming on its head and provides a set of function templates, called algorithms, that work with iterators, and therefore with almost any container.
Most of the standard algorithms are declared in the
<algorithm> header, with some numerical algorithms in
<numeric>, and a few algorithms in
<memory> for working with uninitialized buffers. Unless otherwise mentioned, the function templates in this section are declared in
<algorithm>. This section organizes the algorithms in groups of related functions. To find a specific algorithm by name, check the index.
The type of every function parameter in this section is a type template parameter. For the sake of brevity, the template header is omitted from each declaration. The compiler usually deduces the template parameter types. If you must specify an explicit template argument, the order of the template parameters matches the order of their use in the function parameters.
The names of the template parameters tell you what kind of template argument is expected, especially the iterator category. The iterator category is the minimal functionality needed, so you can, for example, use a random access ...