Chapter 10. The Standard Template Library

What you will learn in this Chapter:

  • The capabilities offered by the STL

  • How to create and use containers

  • How to use iterators with containers

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

  • How to use function objects with the STL

  • How to define lambda expressions and use them with the STL

  • How to use polymorphic function wrappers with lambda expressions

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

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++ 2010 you have an additional version of the STL available that contains templates and generic functions that you can instantiate with 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 ...

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