Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/MicrosoftDocs/cpp-docs/llms.txt

Use this file to discover all available pages before exploring further.

The Microsoft C++ Standard Library — commonly called the STL — is a rich collection of class templates, functions, and objects declared across more than 100 standard headers. It covers everything from type-safe containers and generic algorithms to I/O streams, concurrency primitives, and compile-time utilities. Microsoft’s implementation ships with Visual Studio and satisfies both the hosted and freestanding requirements of the ISO C++ standard.
Microsoft’s implementation of the C++ Standard Library is sometimes referred to as the STL or Standard Template Library for historical reasons. Technically, “C++ Standard Library” is the official ISO 14882 term. The MSVC STL is open-source and maintained at github.com/microsoft/STL.

Hosted vs. Freestanding Implementations

The C++ standard defines two conformance tiers:
  • A hosted implementation supports every required standard header. MSVC satisfies this tier for ordinary application and library development.
  • A freestanding implementation requires only a minimal subset of headers, suitable for kernels, firmware, or embedded targets without an OS.
MSVC satisfies both tiers. The required freestanding headers include:
HeaderHeaderHeader
<atomic><functional><ranges>
<bit><initializer_list><ratio>
<cfloat><iterator><tuple>
<climits><limits><type_traits>
<compare><memory><typeinfo>
<concepts><new><utility>
<coroutine><source_location><version>
<cstdarg><cstddef><exception>
<cstdint><cstdlib>

C++ Standard Conformance

MSVC’s STL implementation tracks the ISO C++ standard closely:

C++17

Full conformance. Features include std::optional, std::variant, std::string_view, parallel algorithms, std::filesystem, structured bindings, and if constexpr.

C++20

Full conformance. Adds concepts, ranges, coroutines, std::format, std::jthread, std::span, std::bit_cast, calendar/timezone in <chrono>, and more.

C++23

Ongoing implementation. Adds std::expected, std::flat_map, std::mdspan, std::print, std::generator, and further ranges improvements.
Enable the desired language version with the /std:c++17, /std:c++20, or /std:c++latest compiler flag.
// Compile with: cl /std:c++20 /EHsc example.cpp
#include <format>
#include <iostream>

int main()
{
    std::cout << std::format("Hello, {}!\n", "C++20");
}

Including Headers

Every C++ Standard Library entity is declared in one or more standard headers. Simply #include the header that defines what you need — no linking step is required for the STL itself when using the MSVC toolchain.
#include <vector>       // std::vector
#include <algorithm>    // std::sort, std::find, ...
#include <string>       // std::string, std::wstring
#include <iostream>     // std::cin, std::cout, std::cerr
#include <thread>       // std::thread
#include <mutex>        // std::mutex, std::lock_guard
#include <future>       // std::async, std::future
#include <numeric>      // std::accumulate, std::reduce
#include <memory>       // std::unique_ptr, std::shared_ptr
#include <filesystem>   // std::filesystem::path (C++17)
#include <format>       // std::format (C++20)
Prefer including only the specific headers you need rather than a catch-all. This keeps build times short and makes dependencies explicit. Unlike some older conventions, there is no single “include everything” header in the C++ Standard Library.

Header Categories

The Standard Library headers fall into several broad categories:
Type-safe collections for storing and organizing data. Includes sequence containers (vector, deque, list, array, forward_list), ordered associative containers (map, set, multimap, multiset), and unordered hash-based containers (unordered_map, unordered_set). See Containers.
More than 100 generic algorithms that operate on iterator ranges: sorting (std::sort, std::stable_sort), searching (std::find, std::binary_search), transforming (std::transform, std::for_each), and numeric operations (std::accumulate, std::reduce). C++20 adds the Ranges library. See Algorithms.
String types (std::string, std::wstring, std::string_view), console I/O (cin, cout, cerr), file streams, string streams, and type-safe formatting with std::format (C++20). See Strings and I/O.
Portable multi-threading with std::thread and std::jthread (C++20), mutual exclusion with std::mutex and RAII guards, synchronization with std::condition_variable, asynchronous tasks with std::async and std::future, and lock-free programming with std::atomic. See Concurrency.
Abstractions that decouple algorithms from containers. Five classical categories (input, output, forward, bidirectional, random-access) plus C++20 contiguous iterators. Range-based for loops use iterators transparently.
Arithmetic algorithms, mathematical functions, complex numbers, value arrays for numeric computing, and a flexible pseudo-random number generation framework.
Pairs and tuples, type-safe discriminated unions (std::variant), nullable values (std::optional), type-erased storage (std::any), function wrappers (std::function), and smart pointers (unique_ptr, shared_ptr, weak_ptr).
Base exception types, standard derived exceptions (e.g., std::out_of_range, std::invalid_argument), and std::error_code / std::error_condition for portable system error reporting.

Thread Safety

Individual objects in the C++ Standard Library are not thread-safe for simultaneous write access. Multiple concurrent reads on the same object are generally safe. When sharing objects across threads always use appropriate synchronization (std::mutex, std::atomic, etc.). The <iostream> global objects (cout, cin, cerr) are thread-safe at the level of individual stream insertions and extractions, but interleaving of output from multiple threads is not ordered unless you serialize externally.

See Also

Build docs developers (and LLMs) love