C++ includes a variety of utility libraries that provide functionality ranging from
to
. These libraries can be broadly divided into two groups:
language support libraries, and
general-purpose libraries.
Language support
Language support libraries provide classes and functions that interact closely with language features and support common language idioms.
(since C++20)
The header
supplies implementation-dependent information about the C++ standard library (such as the version number and release date). It also defines the
.
Basic types (e.g.
,
), RTTI (e.g.
)
Termination (e.g.
,
), environment (e.g.
), signals (e.g.
).
Smart pointers (e.g.
), allocators (e.g.
or
), C-style memory management (e.g.
).
Exceptions (e.g.
,
), assertions (e.g.
).
Support for functions that take an arbitrary number of parameters (via e.g.
,
,
).
(since C++11)
Source code information capture
(since C++20)
Three-way comparison (since C++20)
Defined in header
three_way_comparablethree_way_comparable_with
(C++20)(C++20)
specifies that operator <=> produces consistent result on given types
(concept)
(C++20)
the result type of 3-way comparison that supports all 6 operators, is not substitutable, and allows incomparable values
(class)
(C++20)
the result type of 3-way comparison that supports all 6 operators and is not substitutable
(class)
(C++20)
the result type of 3-way comparison that supports all 6 operators and is substitutable
(class)
is_eqis_neqis_ltis_lteqis_gtis_gteq
(C++20)
named comparison functions
(function)
(C++20)
constrained function object implementing x<=>y
(class)
(C++20)
obtains the result type of the three-way comparison operator <=> on given types
(class template)
(C++20)
the strongest comparison category to which all of the given types can be converted
(class template)
(C++20)
performs 3-way comparison and produces a result of type std::strong_ordering
(customization point object)
(C++20)
performs 3-way comparison and produces a result of type std::weak_ordering
(customization point object)
(C++20)
performs 3-way comparison and produces a result of type std::partial_ordering
(customization point object)
(C++20)
performs 3-way comparison and produces a result of type std::strong_ordering, even if operator<=> is unavailable
(customization point object)
(C++20)
performs 3-way comparison and produces a result of type std::weak_ordering, even if operator<=> is unavailable
(customization point object)
compare_partial_order_fallback
(C++20)
performs 3-way comparison and produces a result of type std::partial_ordering, even if operator<=> is unavailable
(customization point object)
(C++26)
performs three-way comparison on types
(class template)
(since C++20)
Types for
support (e.g.
,
).
(since C++26)
Types for
support (e.g.
std::contracts::contract_violation
).
General-purpose utilities
Swap
swaps the values of two objects
(function template)
(C++14)
replaces the argument with a new value and returns its previous value
(function template)
(C++20)
swaps the values of two objects
(customization point object)
Type operations (since C++11)
Defined in header
(C++11)
forwards a function argument and use the type template argument to preserve its value category
(function template)
(C++23)
forwards a function argument as if casting it to the value category and constness of the expression of specified type template argument
(function template)
(C++11)
converts the argument to an xvalue
(function template)
(C++11)
converts the argument to an xvalue if the move constructor does not throw
(function template)
(C++17)
obtains a reference to const to its argument
(function template)
(C++11)
obtains a reference to an object of the template type argument for use in an unevaluated context
(function template)
(C++23)
converts an enumeration to its underlying type
(function template)
Integer comparison functions (since C++20)
Relational operators (until C++20)
Construction tags (since C++11)
and
Defined in header
implements binary tuple, i.e. a pair of values
(class template)
Defined in header
(C++11)
implements fixed size container, which holds elements of possibly different types
(class template)
(C++17)
calls a function with a tuple of arguments
(function template)
(C++17)
construct an object with a tuple of arguments
(function template)
(since C++11)Defined in header
Defined in header
Defined in header
Defined in header
Defined in header
(C++11)
obtains the number of elements of a
type
(class template)
(C++11)
obtains the element types of a
type
(class template)
Sum types and type erased wrappers (since C++17)
Defined in header
(C++17)
a wrapper that may or may not hold an object
(class template)
Defined in header
(C++23)
a wrapper that contains either an expected or error value
(class template)
Defined in header
(C++17)
a type-safe discriminated union
(class template)
Defined in header
(C++17)
objects that hold instances of any
type
(class)
(since C++20)
The header
provides several function templates to access, manipulate, and process individual bits and bit sequences. The byte ordering (
) of scalar types can be inspected via std::endian facility.
(since C++11)
Partial function application (e.g.
) and related utilities: utilities for binding such as
and
, polymorphic function wrappers:
, predefined functors (e.g.
,
), pointer-to-member to function converters
.
(since C++11)
See also