Standard Template Library

Package that (finally!) exploits CeePlusPlus to its farthest abilities, making it competitive with high-level languages for set manipulation and higher-order functions. Should not be confused with the Standard Library.

The Standard Library for CeePlusPlus adopted a subset of the STL along with many other classes from other sources. Using STL and Standard Library interchangeably is a common mistake that should be avoided. For example, the STL does not support numeric_limits, facets, locales, basic_string, iostreams, and so on. STL was a generic algorithms and data-structures library originally developed by AlexanderStepanov for Ada and then ported to CeePlusPlus before being accepted into the C++ Standard Library.


I know all about the wonderful things which the STL allows and all the mistakes which it protects against. However, I find the code to be hard to read and understand. Perhaps if I just applied myself harder... -- JavaSchrod

Try looking at the BoostLambdaLibrary. -- JohnFletcher


The STL is an extensible generic library; it uses the template mechanism of C++ extensively to provide a set of algorithms (strictly, a name such as "solvers", suggested by DietmarKuehl?, might be more appropriate) which can operate efficiently on arbitrary sequences via the Iterator abstraction. As a convenience, a number of containers are supplied as part of the STL, covering simple needs such as lists, maps, sets etc., but user-defined containers can equally well use the pre-defined algorithms (by exposing suitable iterators) and user-defined algorithms can operate on the pre-defined containers (or on other sequences).

The C++ Standard Library has been integrated with STL concepts, so that the STL algorithms can operate on sequences based on IOStreams (via stream iterators, of course).

The STL uses C++ techniques such as template specialization to allow algorithms to be implemented more efficiently when more capable iterator types are used, but to fall back to more basic implementations for other iterator types.

My favourite book on the STL is Matt Austern's book (listed below, I see). For more information on the whole Standard Library, Josuttis is the man to read. -- JamesDennett


Matthew H. Austern, "GenericProgrammingAndTheStl : Using and Extending the C++ StandardTemplateLibrary". Addison-Wesley, 1999, hardcover, 608 p., ISBN 0-201-30956-4 .

Nicolai M. Josuttis, "TheCppStandardLibrary: A Tutorial and Reference". Addison-Wesley, 1999, Hardcover, 799 pages, ISBN 0-201-37926-0 .

Leen Ammeraal, "STL for C++ Programmers". John Wiley, 1998, Soft cover, 226 pages, ISBN 0-471-97181-2 .


If you are doing anything with the StandardTemplateLibrary, I highly recommend that you run, not walk, to your bookstore and get the excellent ScottMeyers book EffectiveStl. It is one of the best CeePlusPlus books in recent years. -- sg


I must comment that, although ScottMeyers' book is an excellent one, I've more often than not seen it being used as a guide to "impressing your friends with incredibly unreadable code tricks". -- AnonymousCoward


See StlPort StlStyle StlSucks StlIsNotTheCppStandardLibrary ConceptCpp StlFilt


CategoryCpp CategoryCppTemplates CategoryBooks


EditText of this page (last edited November 7, 2010) or FindPage with title or text search