Chapter 10. The Standard Template Library

At its name implies, the Standard Template Library (STL) is a library of standard class and function templates. You can use these templates to create a wide range of powerful general-purpose classes for organizing your data as well as functions for processing that data in various ways. The STL is defined by the standard for native C++ and is therefore always available with a conforming compiler. Because of its broad applicability, the STL can greatly simplify programming in many of your C++ applications.

Of course, the STL for native C++ does not work with C++/CLI class types but in Visual C++ 2008 you have an additional version of the STL available that contains templates and generic functions that you can instantiate with C++/CLI class types.

In this chapter you will learn:

  • What capabilities are offered by the STL

  • What containers are and how you create and use them

  • What iterators are and how you use them with containers

  • The types of algorithms that are available with the STL and how you can apply the more common ones

  • What function objects are and how they are used with the STL

  • How to use the STL version that supports C++/CLI class types

What Is the Standard Template Library?

The STL is a large collection of class and function templates that is provided with your native C++ compiler. I'll first explain in general terms the kinds of resources the STL provides and how they interact with one another before diving into the detail of working examples. ...

Get Ivor Horton's Beginning Visual C++®2008 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.