What is the STL in C++?

The STL has three main parts:

  • Containers: vector, list, map, set, unordered_map, stack, queue.
  • Iterators: objects which point to the items of a container.
  • Algorithms: sort, find, count, transform, accumulate and many more.
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
    std::vector<int> v = {4, 1, 3};
    std::sort(v.begin(), v.end());
    for (int x : v) std::cout << x << ' ';
    std::cout << '\n';
}
Output

1 3 4

See STL Containers and Algorithms.


Learn more about the similar topics:
Tutorials
C++ Templates and Generic Programming
C++ STL Containers: map, set, unordered_map, queue and stack
C++ Algorithms and Iterators
Exercises & Assignments
Write a generic maximum template
Count the frequency of words with a map
Remove duplicates from a vector and keep the order
Interview Questions & Answers
What is the STL in C++?
What is the difference between std::map and std::unordered_map?
What is the difference between push_back and emplace_back in C++?
What is iterator invalidation in C++?
What is the difference between templates and macros in C++?