Skip to content
Related Articles

Related Articles

The C++ Standard Template Library (STL)
  • Difficulty Level : Easy
  • Last Updated : 17 Feb, 2021

The Standard Template Library (STL) is a set of C++ template classes to provide common programming data structures and functions such as lists, stacks, arrays, etc. It is a library of container classes, algorithms, and iterators. It is a generalized library and so, its components are parameterized. A working knowledge of template classes is a prerequisite for working with STL.

STL has four components

  • Algorithms
  • Containers
  • Functions
  • Iterators

Algorithms

The header algorithm defines a collection of functions especially designed to be used on ranges of elements.They act on containers and provide means for various operations for the contents of the containers.

Containers



Containers or container classes store objects and data. There are in total seven standard “first-class” container classes and three container adaptor classes and only seven header files that provide access to these containers or container adaptors.

  • Sequence Containers: implement data structures which can be accessed in a sequential manner.
  • Container Adaptors : provide a different interface for sequential containers.
  • Associative Containers : implement sorted data structures that can be quickly searched (O(log n) complexity).
  • Unordered Associative Containers : implement unordered data structures that can be quickly searched

    Flowchart of Adaptive Containers and Unordered Containers

    Flowchart of Sequence conatiners and ordered containers

Functions

The STL includes classes that overload the function call operator. Instances of such classes are called function objects or functors. Functors allow the working of the associated function to be customized with the help of parameters to be passed.

Iterators

As the name suggests, iterators are used for working upon a sequence of values. They are the major feature that allow generality in STL.

Utility Library

Defined in header <utility>.

References:

Recent articles on STL!

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for foundation plus STL.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.
My Personal Notes arrow_drop_up
Recommended Articles
Page :