| Tutorial: “Introduction to the Standard Template Library (STL).” Excerpt from C++ How to Program 5/e discusses the C++ Standard Template Library (STL) and its three key components—containers, iterators and algorithms. We begin with an overview of the STL's seven first-class containers and three container adapters, then present the common functionality provided by most of these containers. Next, we discuss the five categories of STL iterators and the capabilities provided for each category. Finally, we overview STL algorithms. Using iterators with STL algorithms enables you to perform complex operations on the elements of various STL containers (and standard arrays), often without regard for the underlying container's implementation. For example, using iterators and the STL's copy algorithm, you can copy the elements of a container to another container (possibly of an unrelated container type), to a file or to the standard output with a single line of code! |