Utility library
C++ includes a variety of utility libraries that provide functionality ranging from bit-counting to partial function application. These libraries can be broadly divided into two groups:
- language support libraries, and
- general-purpose libraries.
Contents
- 1 Language support
- 1.1 Implementation properties (since C++20)
- 1.2 Type support
- 1.3 Program utilities
- 1.4 Dynamic memory management
- 1.5 Error handling
- 1.6 Variadic functions
- 1.7 Initializer lists (since C++11)
- 1.8 Source code information capture (since C++20)
- 1.9 Three-way comparison (since C++20)
- 1.10 Coroutine support (since C++20)
- 1.11 Contract support (since C++26)
- 2 General-purpose utilities
- 2.1 Swap
- 2.2 Type operations (since C++11)
- 2.3 Integer comparison functions (since C++20)
- 2.4 Relational operators (until C++20)
- 2.5 Construction tags (since C++11)
- 2.6 Pairs and tuples
- 2.7 Sum types and type erased wrappers (since C++17)
- 2.8 Bitset
- 2.9 Bit manipulation (since C++20)
- 2.10 Function objects (since C++11)
- 2.11 Hash support (since C++11)
- 2.12 See also
[edit] Language support
Language support libraries provide classes and functions that interact closely with language features and support common language idioms.
[edit] Implementation properties (since C++20)
The header <version> supplies implementation-dependent information about the C++ standard library (such as the version number and release date). It also defines the library feature-test macros.
[edit] Type support
Basic types (e.g. std::size_t , std::nullptr_t ), RTTI (e.g. std::type_info )
[edit] Program utilities
Termination (e.g. std::abort , std::atexit ), environment (e.g. std::system ), signals (e.g. std::raise ).
[edit] Dynamic memory management
Smart pointers (e.g. std::shared_ptr ), allocators (e.g. std::allocator or std::pmr::memory_resource ), C-style memory management (e.g. std::malloc ).
[edit] Error handling
Exceptions (e.g. std::exception , std::terminate ), assertions (e.g. assert ).
[edit] Variadic functions
Support for functions that take an arbitrary number of parameters (via e.g. va_start , va_arg , va_end ).
[edit] Initializer lists (since C++11)
<initializer_list>
[edit] Source code information capture (since C++20)
<source_location>
(class) [edit]
[edit] Three-way comparison (since C++20)
<compare>
(class) [edit]
(class) [edit]
(class) [edit]
(class template) [edit]
(class template) [edit]
std::strong_ordering
(customization point object)[edit]
std::weak_ordering
(customization point object)[edit]
std::partial_ordering
(customization point object)[edit]
std::strong_ordering
, even if operator<=> is unavailable(customization point object)[edit]
std::weak_ordering
, even if operator<=> is unavailable(customization point object)[edit]
std::partial_ordering
, even if operator<=> is unavailable(customization point object)[edit]
[edit] Coroutine support (since C++20)
Types for coroutine support (e.g. std::coroutine_traits , std::coroutine_handle ).
[edit] Contract support (since C++26)
Types for contract support (e.g. std::contracts::contract_violation).
[edit] General-purpose utilities
[edit] Swap
<utility>
(function template) [edit]
<concepts>
[edit] Type operations (since C++11)
<utility>
(function template) [edit]
(function template) [edit]
(function template) [edit]
(function template) [edit]
[edit] Integer comparison functions (since C++20)
<utility>
(function template) [edit]
(function template) [edit]
[edit] Relational operators (until C++20)
<utility>
std::rel_ops
(function template) [edit]
[edit]
<utility>
[edit] Pairs and tuples
<utility>
<tuple>
(class template) [edit]
Tuple protocol (since C++11)
<tuple>
<utility>
<array>
<ranges>
<complex>
[edit] Sum types and type erased wrappers (since C++17)
<optional>
<expected>
<variant>
<any>
[edit] Bitset
<bitset>
[edit] Bit manipulation (since C++20)
The header <bit> provides several function templates to access, manipulate, and process individual bits and bit sequences. The byte ordering (endianness) of scalar types can be inspected via std::endian facility.
[edit] Function objects (since C++11)
Partial function application (e.g. std::bind ) and related utilities: utilities for binding such as std::ref and std::placeholders , polymorphic function wrappers: std::function , predefined functors (e.g. std::plus , std::equal_to ), pointer-to-member to function converters std::mem_fn .
[edit] Hash support (since C++11)
<functional>