Chapter 16Understanding Containers and Iterators

  • Explaining iterators
  • Containers Overview: requirements on elements, general error handling, and iterators
  • Sequential Containers: vector, deque, list, forward_list, and array
  • Container Adapters: queue, priority_queue, and stack
  • Associative Containers: the pair utility, map, multimap, set, and multiset
  • Unordered Associative Containers/Hash Tables: unordered_map, unordered_multimap, unordered_set, and unordered_multiset
  • Other Containers: standard C-style arrays, strings, streams, and bitset

Please note that all the code examples for this chapter are available as a part of this chapter’s code download on the book’s website at on the Download Code tab.

Chapter 15 introduces the STL, describes its basic philosophy, and provides an overview of the various containers and algorithms. This chapter begins a more-in-depth tour of the STL by covering the STL containers. A detailed list of available classes and methods can be found in a Standard Library Reference; for example, or

The next chapters go deeper on topics such as algorithms, regular expressions, and how you can customize and extend the STL.


Containers in the STL are generic data structures useful for storing collections of data. You should rarely need to use a standard C-style array, write a linked list, or ...

Get Professional C++, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.