Do NOT use for questions about 3D CAD model. Use [stl-format] instead. The Standard Template Library, or STL, is a C++ library of generic containers, iterators, algorithms, and function objects. Use in conjunction with [c++]. When C++ was standardised, large parts of the STL were adopted into the Standard Library, and these parts in the Standard Library are also sometimes erroneously referred to collectively as "the STL".
The Standard Template Library, or STL, is a C++ library of generic containers, iterators, algorithms, and function objects. Originally designed by Alexander Stepanov and Meng Lee and published by HP in 1995. Large parts of the STL were adopted with modifications into the ISO C++ Standard Library.
Note that the name STL is ambiguous, as it may refer to different things. The following are the typical intended meanings (suggested tagging in brackets):
- The original HP implementation (stl or hp-stl)
- The SGI STL library (stl or sgi-stl)
- The HP STL derived portions of the C++ standard library (stl and stdlib)
- The template portions of the C++ standard library (stl and stdlib)
- The entire C++ standard library (c++-standard-library and stdlib)
The last two definitions are, strictly speaking, incorrect; the C++ standard never mentions either "STL" or "Standard Template Library". In practice, however, people rarely need to refer to the HP library, and so "STL" is nearly always used to describe the STL-derived parts of the standard library instead (the algorithms, iterators and containers), or the template portions.
Programming Elements
Most of the STL's programming elements are in the std
namespace. Containers, algorithms, iterators and other helper constructs exist in various headers within the std
namespace. The basic and most common used container, vector
can be used by:
- Including the header
<vector>
- Declaring the variable by its full scoped name:
std::vector<int> IntV;
- Including whole of
std
(considered bad practice):using namespace std; vector<int> IntV;
- Using the specific symbol:
using std::vector; vector<int> IntV;
All other programming elements can be used by a similar pattern.
The beauty of STL is that containers (list
, unordered_map
, etc.), algorithms (sort
, count_if
, etc.), and iterators (reverse iterator, const iterator, etc.) are not dependent on each other but can be used together without knowing the internals of the other element. Containers and algorithms are connected by iterators.
Resources
*This reference is non-normative.
Books
The C++ Standard Library: A Tutorial and Reference (2nd Edition) Chapter 6: The Standard Template Library