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
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 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
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.
As the name suggests, iterators are used for working upon a sequence of values. They are the major feature that allow generality in STL.
Defined in header <utility>.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Set in C++ Standard Template Library (STL)
- Map in C++ Standard Template Library (STL)
- Containers in C++ STL (Standard Template Library)
- Multiset in C++ Standard Template Library (STL)
- Queue in Standard Template Library (STL)
- Multimap in C++ Standard Template Library (STL)
- Deque in C++ Standard Template Library (STL)
- Sort in C++ Standard Template Library (STL)
- List in C++ Standard Template Library (STL)
- Pair in C++ Standard Template Library (STL)
- Priority Queue in C++ Standard Template Library (STL)
- Unordered Sets in C++ Standard Template Library
- Binary Search in C++ Standard Template Library (STL)
- is_final template in C++14
- is_void template in C++
- is_volatile template in C++
- is_reference Template in C++
- is_lvalue_reference Template in C++
- is_const Template in C++
- std::is_compound Template in C++