O'Reilly logo

The C++ Standard Library: A Tutorial and Reference, Second Edition by Nicolai M. Josuttis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. STL Algorithms

This chapter describes all the algorithms of the C++ standard library. It begins with an overview of the algorithms and some general remarks about them. The chapter then presents the exact signature of each algorithm and one or more examples of its use.

11.1. Algorithm Header Files

To use the algorithms of the C++ standard library, you must include the header file <algorithm>:

#include <algorithm>

This header file also includes some auxiliary functions: min(), max(), and minmax() were presented in Section 5.5.1, page 134. The iter_swap() iterator function was discussed in Section 9.3.4, page 446.

Some of the STL algorithms are provided for numeric processing. Thus, they are defined in <numeric>:

#include <numeric>

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required