5

Standard Library Containers, Algorithms, and Iterators

The C++ standard library has evolved a lot with C++11/14/17/20, and now C++23. However, at its core still sit three main pillars: containers, algorithms, and iterators. They are all implemented as generic types and general-purpose function templates. In this chapter, we’ll look at how they can be employed together to achieve various goals.

We will cover the following recipes in this chapter:

  • Using vector as a default container
  • Using bitset for fixed-size sequences of bits
  • Using vector<bool> for variable-size sequences of bits
  • Using the bit manipulation utilities
  • Finding elements in a range
  • Sorting a range
  • Initializing a range
  • Using set operations on a range
  • Using iterators to insert new ...

Get Modern C++ Programming Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.