edgepedia

Technology and the built world / Computing and digital systems / Software and programming / Development tools and collaboration infrastructure / Frameworks, libraries, and APIs / Mobile and platform frameworks

General · Edgepedia8 min read

C++ Standard Library

The C++ Standard Library is the set of headers, components, and behavioral guarantees specified in the ISO C++ standard (ISO/IEC 14882). It supplies containers, iterators, ranges, algorithms, strings, numerics, input/output, diagnostics, memory management, utilities, and concurrency support, almost all of it declared in the namespace std.1 • 2 The library is not a separate document: it is defined inside the language standard itself, and it constitutes about three quarters of the C++20 standard's text.3

Key factDetail
Defining documentISO/IEC 14882; the standard library is about 3/4 of the C++20 standard3
NamespaceAll library entities except operator new and operator delete live in std or namespaces nested within it2
Implementation kindsHosted implementations provide all required headers; freestanding implementations provide an implementation-defined subset1
Major implementationslibstdc++ (GPL v3 + runtime exception), libc++ (Apache 2.0 + LLVM exception), MSVC STL (Apache 2.0 + LLVM exception)4 • 5
Reachlibc++ is the default library on macOS, iOS, watchOS, tvOS, Android, and FreeBSD, with an estimated user base of over 1 billion daily active users6
Adoption (2024 survey)90.81% of respondents use C++11 features "pretty much"; 20.02% report full use of C++23 features such as expected and md_span7
Compile costIncluding the whole C++23 library expands to 128,846 lines under GCC (1,175 ms net compile time) and 87,186 lines under Clang (1,598 ms)8
Safety directionC++26 standard library hardening adds runtime-checked hardened preconditions against out-of-bounds access in containers, span, mdspan, string, and string_view9

Structure and components

Each element of the library is declared or defined in a header, and the set of headers grows with every revision of the standard.10 C++11 added <condition_variable>, <forward_list>, <unordered_map>, <type_traits>, and others; C++17 added <memory_resource> and <string_view>; C++20 added <stop_token> and <source_location>; C++23 added <flat_map> and <flat_set>; C++26 adds <hazard_pointer>, <inplace_vector>, and <text_encoding>.2 Regular expression matching arrived with C++11, text formatting with C++20, and text encoding identification with C++26.2

The library is organized into named sub-libraries: language support, diagnostics, memory management, general utilities, the containers/iterators/ranges/algorithms group, strings, text processing, numerics, and execution support.2 An empirical study of library use counts 11 sub-libraries, 8 established before C++11 (Containers, Iterators, Algorithms, Utilities, Strings, Numerics, Input/Output, Localizations) plus 3 added by C++11 (Regular Expressions, Atomic Operations, Thread Support).11 The containers, iterators, ranges, and algorithms clauses are described by the standard itself as providing access to a subset of the most widely used algorithms and data structures.1

Since C++23, a named module std exports the declarations in namespace std provided by the importable library headers, offering an alternative to textual #include.2

Design and extension mechanisms

The library's original extension point is the allocator. Alexander Stepanov's Standard Template Library addressed portability across memory models by providing a standard set of requirements for allocators, objects that encapsulate memory-model information, and all STL containers are parameterized in terms of allocators; this design carried into the standardized library.12

Guarantees: complexity, exceptions, and safety

The standard distinguishes hosted and freestanding implementations. A hosted implementation supports all of the required standard library headers; a freestanding implementation has an implementation-defined set of headers.1 • 5

In a non-hardened implementation, container accessors such as vector::operator[] do not range-check; out-of-range access is undefined behavior. C++26 addresses this through standard library hardening. The hardening proposal focuses on hardened preconditions that prevent out-of-bounds memory access, targeting accessors of sequence containers, std::span, std::mdspan, std::string, std::string_view, modifiers like pop_back, and accessors of optional and expected.9 In a hardened implementation, hardened preconditions are checked at runtime and a violation is a contract assertion with terminating semantics, evaluated before any other observable side effect of the function; these checks cannot be bypassed with the ignore contract semantic.2 • 9 Hardening is designed to avoid ABI (application Binary Interface: compiled code's binary-level compatibility contract) changes and for production use, and the mechanism to request it is implementation-defined, for example a compiler flag like -fhardened or a macro such as -D_LIBCPP_HARDENING_MODE=.9

Implementations

Three implementations dominate. libstdc++ ships with GCC under the GPL v3 with a runtime exception; libc++ ships with Clang under Apache 2.0 with the LLVM exception; Microsoft's MSVC STL is released under the Apache License 2.0 with LLVM Exceptions.4 • 5 Microsoft's distribution additionally includes <hash_map> and <hash_set>, headers not required by the C++ Standard.5

ABI and layout differ in visible ways. libstdc++ supports a dual ABI selected by _GLIBCXX_USE_CXX11_ABI; libc++ versions its symbols through the __1 inline namespace; MSVC STL aligns its ABI with Visual Studio versions. Debug modes that add checking (_GLIBCXX_DEBUG, _ITERATOR_DEBUG_LEVEL) break ABI, while _LIBCPP_HARDENING_MODE does not.4 Small-string optimization also differs: libc++ uses a 22-byte SSO buffer for std::string on 64-bit platforms versus 15 bytes in libstdc++ and MSVC STL, giving sizeof(std::string) of 24 bytes versus 32 bytes.4

Completeness varies by feature. As of LLVM 18, libc++ shipped no parallel algorithms, while libstdc++ did; MSVC STL also lacked them.4 libc++ fully implements C++11 and C++14, with C++17, C++20, C++23, C++26, and C++29 support marked in progress.6 For GCC 14, Clang 18, and VS 2022 17.10+, std::print/println, std::expected, std::flat_map/flat_set, std::mdspan, std::move_only_function, std::stacktrace, std::out_ptr/inout_ptr, and std::byteswap are available; std::generator is complete only in libc++, and std::ranges::to is partial in MSVC STL.4

By the numbers

Compile-time cost is measurable. Including the whole C++23 standard library expands to 128,846 lines of preprocessed code under GCC with 1,175 ms net compile time, and 87,186 lines under Clang with 1,598 ms, up from 75,473 lines / 432 ms and 63,666 lines / 759 ms for the C++11 library.8 Precompiled headers cut the whole-library include cost to 367 ms under GCC and 138 ms under Clang for C++23.8 Within libc++, preprocessed <vector> alone expands to 2,046,574 bytes and <iostream> to 1,906,216 bytes.13

Runtime differences between implementations are small in microbenchmarks. libc++ (Clang 17) constructed a string from const char* in 12 ns versus 15 ns for libstdc++ and 16 ns for MSVC STL, with SSO-path hits at 5 ns versus 8 ns and 7 ns; a vector benchmark showed libstdc++ (GCC 13) pushing back 1 million elements in 12 ms versus 11 ms for libc++ and 13 ms for MSVC STL.4

Adoption tracks standard age. In the 2024 ISO C++ developer survey, 90.81% of respondents reported using C++11 features (auto, move semantics, shared_ptr, lambdas) "pretty much", 77.79% reported full use of C++17 features, 31.61% full use of C++20 features like concepts, coroutines, and modules, and 20.02% full use of C++23 features such as expected and md_span.7

How it compares with Boost, Qt, and platform frameworks

The official name is C++ Standard Library, as defined in ISO 14882. The name "STL" at first denoted Alexander Stepanov's Standard Template Library; when portions of that library were incorporated into the C++ Standard Library, they were joined there by the ISO C runtime library, some Boost library components, and additional features.5

History

The modern library dates to a standards meeting presentation. At the San Jose meeting in November 1993, Alexander Stepanov, then an HP employee, gave a presentation on generic programming that put templates to substantial use; by the San Diego meeting the next March, he had refined his and Meng Lee's Standard Template Library to the point that the committee was ready to seriously consider it, even if it meant delaying completion of the standard.14 Stepanov's own development timeline places the Ada Generic Library with Dave Musser in 1986, STL with Meng Lee and Dave Musser in 1993 to 1994, and SGI STL with Matt Austern and Hans Boehm in 1995 to 1998.15 After approval, STL, along with iostreams, became a centerpiece of the standard C++ library.14

Bjarne Stroustrup, C++'s creator, credits the STL framework of containers, iterators, and algorithms as by far the most important standard-library component, saying that it and the generic programming techniques it pioneered saved C++ as a living modern language.3 C++11 modernized the library substantially: Josuttis's second-edition reference, covering the library as incorporated into C++11, extended its overall content by about 50% over the first edition, adding type traits, tuples, new containers, regular expressions, smart pointers, random numbers, clocks, and concurrency.16 Within that revision, auto_ptr, C++98's early exclusive-ownership pointer, was replaced by shared_ptr for shared ownership and unique_ptr for exclusive ownership.3 The ISO C++ committee itself was founded in 1991 and produced the 1998 ISO standard, the baseline for the library's subsequent growth.17

Recent developments

C++23 was finalized with <flat_map>, <flat_set>, and the std module among its additions.2 For C++26, N5050 is the final draft and the initial draft for C++29, forming the basis of the Draft International Standard for C++26.18 Standard library hardening was adopted for C++26, adding hardened preconditions for certain potentially out-of-bounds accesses to containers, span, mdspan, string, and string_view, whose violations in hardened implementations are checked at runtime and have terminating semantics.9 • 2 On the implementation side, GCC 14, Clang 18, and VS 2022 17.10+ collectively cover the C++23 feature set noted above, with remaining gaps concentrated in std::generator and std::ranges::to.4

References

  1. [C++ working draft, [library], WG21](https://eel.is/c++draft/library)
  2. C++ Standard Library, cppreference.com
  3. Bjarne Stroustrup, Thriving in a Crowded and Changing World: C++ 2006–2020, HOPL IV
  4. Standard Library Implementation, cpp.wyattau.com
  5. C++ Standard Library Overview (STL), Microsoft Learn
  6. libc++ C++ Standard Library documentation, LLVM
  7. 2024 Annual C++ Developer Survey "Lite", Standard C++ Foundation
  8. cxx-std-include-bench, GitHub
  9. P3471R1: Standard Library Hardening, WG21
  10. [C++ working draft, [headers], WG21](https://eel.is/c++draft/headers)
  11. How do developers use C++ libraries? An empirical study, SEKE 2015
  12. The Standard Template Library, Alexander Stepanov
  13. [[libc++] Extreme preprocessed size of core headers, LLVM issue 80196](https://github.com/llvm/llvm-project/issues/80196)
  14. C++: The Making of a Standard; Stroustrup Interviews
  15. STL and Its Design Principles, Alexander Stepanov
  16. The C++ Standard Library, 2nd Edition, Nicolai Josuttis
  17. Evolving a language in and for the real world: C++ 1991–2006, HOPL III, ACM
  18. N5051 Editors' Report, WG21

Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026

© 2026 Biostate AI. Free to use with credit under the Edgepedia Community License. Embed a reference card.

Report an error

C++ Standard Library

Pick at least one reason.