The C++ Standard Template Library (STL)
The C++ Standard Template Library (STL)
Douglas C. Schmidt
[email protected]
www.dre.vanderbilt.edu/~schmidt
Vanderbilt University
Nashville, Tennessee, USA
The C++ STL Douglas C. Schmidt
• What is STL?
• Generic programming: Why use STL?
• Overview of STL concepts & features
– e.g., helper class & function templates, ,
containers, iterators, generic algorithms,
function objects, adapters
• A complete STL example
• References for more information on STL
Vanderbilt University 1
The C++ STL Douglas C. Schmidt
2
See en.wikipedia.org/wiki/Standard_Template_Library
The C++ STL Douglas C. Schmidt
Vanderbilt University 3
The C++ STL Douglas C. Schmidt
3
See en.wikipedia.org/wiki/Generic_programming
The C++ STL Douglas C. Schmidt
3
The C++ STL Douglas C. Schmidt
3
The C++ STL Douglas C. Schmidt
3
The C++ STL Douglas C. Schmidt
Vanderbilt University 4
The C++ STL Douglas C. Schmidt
4
Programmers can thus focus on the (business) problem at hand
The C++ STL Douglas C. Schmidt
4
C++ STL performs static type checking to enhance correctness & performance
The C++ STL Douglas C. Schmidt
• Flexibility
Vanderbilt University 4
The C++ STL Douglas C. Schmidt
auto li = find(l.begin(),
l.end(),
5);
Vanderbilt University 4
The C++ STL Douglas C. Schmidt
Vanderbilt University 4
The C++ STL Douglas C. Schmidt
• Efficiency
Vanderbilt University 4
The C++ STL Douglas C. Schmidt
Vanderbilt University 4
The C++ STL Douglas C. Schmidt
• Efficiency
– Templates & inlining avoids
virtual function overhead
– Strict attention to time
complexity of algorithms
Vanderbilt University 4
The C++ STL Douglas C. Schmidt
5
See en.wikipedia.org/wiki/Template_(C++)
The C++ STL Douglas C. Schmidt
5
The C++ STL Douglas C. Schmidt