C++ STL Tutorial

C++ STL Tutorial


C++ STL Tutorial
STL is stands to Standard Template Libraries. In 1990, Alex Stepanov and Meng Lee of Hewlett Packard Laboratories extended C++ with a library of class and function templates which has come to be known as the STL. In 1994, STL was adopted as part of ANSI/ISO Standard C++.
There are STL has three basic components:
  • Containers: Generic class templates for storing a collection of data.
  • Algorithms: Generic function templates for operating on containers.
  • Iterators: Generalized ‘smart’ pointers that facilitate the use of containers.
They provide an interface that is needed for STL algorithms to operate on STL containers.
String abstraction was added during standardization. 
Why use STL?
  • STL offers an assortment of containers
  • STL publicizes the time and storage complexity of its containers
  • STL containers grow and shrink in size automatically
  • STL provides built-in algorithms for processing containers
  • STL provides iterators that make the containers and algorithms flexible and efficient.
  • STL is extensible which means that users can add new containers and new algorithms such that:
  1. STL algorithms can process STL containers as well as user-defined containers
  2. User-defined algorithms can process STL containers as well user-defined containers