STL (Standard Template Library)

The STL is a core part of the C++ standard library that provides ready-made containers (like vector and map), algorithms (like sort and find), and iterators that connect them.

C++

Containers store collections of data, algorithms operate on that data, and iterators are the glue that lets algorithms work across different containers. Because the STL is built on templates, it works with any type.

Common pieces include std::vector, std::map, std::set, std::sort, and std::find. Using the STL saves you from reinventing well-tested data structures and algorithms.

Examples

C++

#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    std::vector<int> nums = {3, 1, 2};
    std::sort(nums.begin(), nums.end());
    std::cout << nums[0] << nums[1] << nums[2] << std::endl;
    return 0;
}

Output:

123

Learn it in a lesson

See also

Back to the Dictionary