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 provide classes and functions that interact closely with language features and support common language idioms.
Basic types (e.g. std::size_t
, std::nullptr_t
), RTTI (e.g. std::type_info
), type traits (e.g. std::is_integral
, std::rank
).
Smart pointers (e.g. std::shared_ptr
), allocators (e.g. std::allocator
or std::memory_resource
), C-style memory management (e.g. std::malloc
).
Exceptions (e.g. std::exception
, std::logic_error
), assertions (e.g. assert
).
(C++11)
| allows the use of initializer list syntax to initialize non-aggregate types (class template) |
Support for functions that take an arbitrary number of parameters (via e.g. va_start
, va_arg
, va_end
).
Termination (e.g. std::abort
, std::atexit
), environment (e.g. std::system
), signals (e.g. std::raise
).
Time tracking (e.g. std::chrono::time_point
, std::chrono::duration
), C-style date and time (e.g. std::time
, std::clock
).
implements constant length bit array (class) |
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
), method to function converters std::mem_fn
.
Defined in header <optional> |
|
---|---|
(since C++17)
| a wrapper that may or may not hold an object (class template) |
Defined in header <variant> |
|
(since C++17)
| a type-safe discriminated union (class template) |
Defined in header <any> |
|
(since C++17)
| Objects that hold instances of any CopyConstructible type. (class) |
Defined in header <utility> |
|
(since C++17)
| Special tag type used by the in-place construction tags (class) |
(since C++17)
| in-place construction tag (function template) |
implements binary tuple, i.e. a pair of values (class template) |
|
(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) |
(C++11)
| tag type used to select correct function overload for piecewise construction (class) |
(C++11)
| an object of type piecewise_construct_t used to disambiguate functions for piecewise construction (constant) |
(C++14)
| implements compile-time sequence of integers (class template) |
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++11)
| forwards a function argument (function template) |
(C++11)
| obtains an rvalue reference (function template) |
(C++11)
| obtains an rvalue reference if the move constructor does not throw (function template) |
Defined in header <utility> |
|
---|---|
(C++11)
| obtains a reference to its argument for use in unevaluated context (function template) |
(C++17)
| obtains a reference to const to its argument (function template) |
Defined in header <new> |
|
(C++17)
| pointer optimization barrier (function template) |
Defined in header <utility> |
|
---|---|
Defined in namespace std::rel_ops |
|
automatically generates comparison operators based on user-defined operator== and operator< (function template) |
(C++11)
| hash function object (class template) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/utility