11 STL here – The C++ Standard Template Library
This chapter covers
- Exploring the C++ Standard Template Library (STL)
- Understanding how to work with STL containers
- Practicing the use of iterators and understanding their importance
- Practicing some useful STL algorithms
- Exploring the concept of functors (function objects)
In this chapter, we explore one of the most powerful libraries C++ has to offer: The Standard Template Library, also known as the STL. The STL is a comprehensive library with an incredible collection of reusable ready-to-use, high-quality implementations of data structures and algorithms. However, the STL is a huge subject that can cover a whole book, and in this Chapter (and book) we cannot cover it in its entirety.
We start this Chapter by exploring the various containers the STL has to offer, and explain how each container is designed to store and organize data. You will then learn all about iterators - an essential tool for traversing and manipulating elements within containers. You will learn about different iterator types, and their role, and practice some code.
We then move on and explore the fascinating world of STL algorithms. You will learn and practice how to perform a wide range of operations powered by algorithms, such as searching, sorting, shuffling, accumulating values, and more.