Difference between revisions of "cpp/utility"
D41D8CD98F (Talk | contribs) (Undo revision 109900 by 192.185.83.191 (talk)) |
(P1208R6 source_location) |
||
Line 25: | Line 25: | ||
{{dsc begin}} | {{dsc begin}} | ||
+ | {{dsc header | initializer_list}} | ||
{{dsc inc | cpp/utility/dsc initializer_list}} | {{dsc inc | cpp/utility/dsc initializer_list}} | ||
{{dsc end}} | {{dsc end}} | ||
Line 35: | Line 36: | ||
===Implementation properties === | ===Implementation properties === | ||
The header {{header|version}} supplies implementation-dependent information about the C++ standard library (such as the version number and release date. It also defines the [[cpp/utility/feature_test|library feature-test macros]]. | The header {{header|version}} supplies implementation-dependent information about the C++ standard library (such as the version number and release date. It also defines the [[cpp/utility/feature_test|library feature-test macros]]. | ||
+ | |||
+ | ===Source code information capture=== | ||
+ | {{dsc begin}} | ||
+ | {{dsc header | source_location}} | ||
+ | {{dsc inc | cpp/utility/dsc source_location}} | ||
+ | {{dsc end}} | ||
}} | }} | ||
Line 50: | Line 57: | ||
{{dsc begin}} | {{dsc begin}} | ||
+ | {{dsc header | bitset}} | ||
{{dsc inc | cpp/utility/dsc bitset}} | {{dsc inc | cpp/utility/dsc bitset}} | ||
{{dsc end}} | {{dsc end}} | ||
Line 144: | Line 152: | ||
{{dsc end}} | {{dsc end}} | ||
− | + | {{langlinks|ar|cs|de|es|fr|it|ja|ko|pl|pt|ru|zh}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Revision as of 00:40, 12 August 2019
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 |
Language support
Language support libraries provide classes and functions that interact closely with language features and support common language idioms.
Type support
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)
Dynamic memory management
Smart pointers (e.g. std::shared_ptr), allocators (e.g. std::allocator or std::memory_resource), C-style memory management (e.g. std::malloc)
Error handling
Exceptions (e.g. std::exception, std::terminate), assertions (e.g. assert)
Initializer lists
Defined in header
<initializer_list> | |
(C++11) |
references a temporary array created in list-initialization (class template) |
Variadic functions
Support for functions that take an arbitrary number of parameters (via e.g. va_start, va_arg, va_end)
Implementation propertiesThe 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. Source code information capture
|
(since C++20) |
General-purpose utilities
Program utilities
Termination (e.g. std::abort, std::atexit), environment (e.g. std::system), signals (e.g. std::raise)
Date and time
Time tracking (e.g. std::chrono::time_point, std::chrono::duration), C-style date and time (e.g. std::time, std::clock)
Bitset
Defined in header
<bitset> | |
implements constant length bit array (class template) |
Function objects
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.
Optional, variant and any
Defined in header
<optional> | |
(C++17) |
a wrapper that may or may not hold an object (class template) |
Defined in header
<variant> | |
(C++17) |
a type-safe discriminated union (class template) |
Defined in header
<any> | |
(C++17) |
objects that hold instances of any CopyConstructible type (class) |
Defined in header
<utility> | |
in-place construction tag (tag) |
Pairs and tuples
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) |
piecewise construction tag (tag) | |
(C++14) |
implements compile-time sequence of integers (class template) |
Swap, forward and move
Defined in header
<utility> | |
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 and use the type template argument to preserve its value category (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) |
Defined in header
<concepts> | |
(C++20) |
swaps the values of two objects (customization point object) |
Type operations
Defined in header
<utility> | |
(C++11) |
obtains a reference to an object of the template type argument for use in an 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) |
Relational operators and comparison
Defined in header
<compare> | |
(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) |
named comparison functions (function) | |
(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) |
Defined in header
<utility> | |
Defined in namespace
std::rel_ops | |
(deprecated in C++20) |
automatically generates comparison operators based on user-defined operator== and operator< (function template) |
Elementary string conversions
In addition to sophisticated locale-dependent parsers and formatters provided by the C++ I/O library, the C I/O library, C++ string converters, and C string converters, the header <charconv> provides light-weight, locale-independent, non-allocating, non-throwing, ASCII-only parsers and formatters for arithmetic types.
Defined in header
<charconv> | |
(C++17) |
converts an integer or floating-point value to a character sequence (function) |
(C++17) |
converts a character sequence to an integer or floating-point value (function) |
(C++17) |
specifies formatting for std::to_chars and std::from_chars (enum) |
Hash support
(C++11) |
hash function object (class template) |