|
1 | 1 | ---
|
2 | 2 | description: "Learn more about: <utility>"
|
3 | 3 | title: "<utility>"
|
4 |
| -ms.date: "11/04/2016" |
| 4 | +ms.date: 11/14/2024 |
5 | 5 | f1_keywords: ["<utility>"]
|
6 | 6 | helpviewer_keywords: ["utility header"]
|
7 |
| -ms.assetid: c4491103-5da9-47a1-9c2b-ed8bc64b0599 |
8 | 7 | ---
|
9 | 8 | # `<utility>`
|
10 | 9 |
|
11 |
| -Defines C++ Standard Library types, functions, and operators that help to construct and manage pairs of objects, which are useful whenever two objects need to be treated as if they were one. |
| 10 | +Defines C++ Standard Library types, functions, and operators that help to construct and manage pairs of objects, which are useful whenever two objects should be treated as if they were one. |
12 | 11 |
|
13 | 12 | ## Requirements
|
14 | 13 |
|
15 |
| -**Header:** \<utility> |
| 14 | +**Header:** `<utility>` |
16 | 15 |
|
17 |
| -**Namespace:** std |
| 16 | +**Namespace:** `std` |
18 | 17 |
|
19 | 18 | ## Remarks
|
20 | 19 |
|
21 |
| -Pairs are widely used in the C++ Standard Library. They are required both as the arguments and return values for various functions and as element types for containers such as [map class](../standard-library/map-class.md) and [multimap class](../standard-library/multimap-class.md). The \<utility> header is automatically included by \<map> to assist in managing their key/value pair type elements. |
22 |
| - |
23 |
| -> [!NOTE] |
24 |
| -> The \<utility> header uses the statement `#include <initializer_list>`. It also refers to `class tuple` as defined in \<tuple>. |
| 20 | +Pairs are widely used in the C++ Standard Library. They're required both as the arguments and return values for various functions and as element types for associative containers like [`map`](../standard-library/map-class.md) and [`multimap`](../standard-library/multimap-class.md). |
25 | 21 |
|
26 | 22 | ## Members
|
27 | 23 |
|
28 | 24 | ### Classes
|
29 | 25 |
|
30 | 26 | |Type|Description|
|
31 | 27 | |-|-|
|
32 |
| -|[chars_format](../standard-library/chars-format-class.md)|Floating-point format for primitive numerical conversion.| |
33 |
| -|[tuple_element](../standard-library/tuple-element-class-tuple.md)|A class that wraps the type of a `pair` element.| |
34 |
| -|[tuple_size](../standard-library/tuple-size-class-tuple.md)|A class that wraps `pair` element count.| |
| 28 | +|[`chars_format`](../standard-library/chars-format-class.md)|Floating-point format for primitive numerical conversion.| |
| 29 | +|[`tuple_element`](../standard-library/tuple-element-class-tuple.md)|Wraps the type of a `pair` element.| |
| 30 | +|[`tuple_size`](../standard-library/tuple-size-class-tuple.md)|Wraps a `pair` element count.| |
35 | 31 |
|
36 | 32 | ### Objects
|
37 | 33 |
|
38 | 34 | |Template|Description|
|
39 | 35 | |-|-|
|
40 |
| -|[index_sequence](../standard-library/utility-functions.md#index_sequence)|An alias template defined for the common case where `T` is `std::size_t` | |
41 |
| -|[index_sequence_for](../standard-library/utility-functions.md#index_sequence_for)|Helper alias template to convert any type parameter pack into an index sequence of the same length| |
42 |
| -|[make_index_sequence](../standard-library/utility-functions.md#make_index_sequence)| Helper alias template to simplify the creation of a `std::index_sequence` type. | |
43 |
| -|[make_integer_sequence](../standard-library/utility-functions.md#make_integer_sequence)|Helper alias template to simplify the creation of a `std::integer_sequence` type.| |
| 36 | +|[`index_sequence`](../standard-library/utility-functions.md#index_sequence)|An alias template defined for the common case where `T` is `std::size_t` | |
| 37 | +|[`index_sequence_for`](../standard-library/utility-functions.md#index_sequence_for)|Helper alias template to convert any type parameter pack into an index sequence of the same length| |
| 38 | +|[`make_index_sequence`](../standard-library/utility-functions.md#make_index_sequence)| Helper alias template to simplify the creation of a `std::index_sequence` type. | |
| 39 | +|[`make_integer_sequence`](../standard-library/utility-functions.md#make_integer_sequence)|Helper alias template to simplify the creation of a `std::integer_sequence` type.| |
44 | 40 |
|
45 | 41 | ### Functions
|
46 | 42 |
|
47 | 43 | |Function|Description|
|
48 | 44 | |-|-|
|
49 |
| -|[as_const](../standard-library/utility-functions.md#asconst)|Returns type.| |
50 |
| -|[declval](../standard-library/utility-functions.md#declval)|Shorthand expression evaluation.| |
51 |
| -|[exchange](../standard-library/utility-functions.md#exchange)|Assigns a new value to an object and returns its old value.| |
52 |
| -|[forward](../standard-library/utility-functions.md#forward)|Preserves the reference type (either `lvalue` or `rvalue`) of the argument from being obscured by perfect forwarding.| |
53 |
| -|[from_chars](../standard-library/utility-functions.md#from_chars)|| |
54 |
| -|[get](../standard-library/utility-functions.md#get)|A function that gets an element from a `pair` object.| |
55 |
| -|[make_pair](../standard-library/utility-functions.md#make_pair)|A template helper function used to construct objects of type `pair`, where the component types are based on the data types passed as parameters.| |
56 |
| -|[move](../standard-library/utility-functions.md#move)|Returns the passed in argument as an `rvalue` reference.| |
57 |
| -|[move_if_noexcept](../standard-library/utility-functions.md#moveif)|| |
58 |
| -|[swap](../standard-library/utility-functions.md#swap)|Exchanges the elements of two `pair` objects.| |
59 |
| -|[to_chars](../standard-library/utility-functions.md#to_chars)|Converts value into a character string.| |
| 45 | +|[`as_const`](../standard-library/utility-functions.md#asconst)|Returns type.| |
| 46 | +|[`declval`](../standard-library/utility-functions.md#declval)|Shorthand expression evaluation.| |
| 47 | +|[`exchange`](../standard-library/utility-functions.md#exchange)|Assigns a new value to an object and returns its old value.| |
| 48 | +|[`forward`](../standard-library/utility-functions.md#forward)|Preserves the reference type (either `lvalue` or `rvalue`) of the argument from being obscured by perfect forwarding.| |
| 49 | +|[`from_chars`](../standard-library/utility-functions.md#from_chars)|| |
| 50 | +|[`get`](../standard-library/utility-functions.md#get)|A function that gets an element from a `pair` object.| |
| 51 | +|[`make_pair`](../standard-library/utility-functions.md#make_pair)|A template helper function used to construct objects of type `pair`, where the component types are based on the data types passed as parameters.| |
| 52 | +|[`move`](../standard-library/utility-functions.md#move)|Returns the passed in argument as an `rvalue` reference.| |
| 53 | +|[`move_if_noexcept`](../standard-library/utility-functions.md#moveif)|| |
| 54 | +|[`swap`](../standard-library/utility-functions.md#swap)|Exchanges the elements of two `pair` objects.| |
| 55 | +|[`to_chars`](../standard-library/utility-functions.md#to_chars)|Converts value into a character string.| |
60 | 56 |
|
61 | 57 | ### Operators
|
62 | 58 |
|
63 | 59 | |Operator|Description|
|
64 | 60 | |-|-|
|
65 |
| -|[operator!=](../standard-library/utility-operators.md#op_neq)|Tests if the pair object on the left side of the operator is not equal to the pair object on the right side.| |
66 |
| -|[operator==](../standard-library/utility-operators.md#op_eq_eq)|Tests if the pair object on the left side of the operator is equal to the pair object on the right side.| |
67 |
| -|[operator\<](../standard-library/utility-operators.md#op_lt)|Tests if the pair object on the left side of the operator is less than the pair object on the right side.| |
68 |
| -|[operator\<=](../standard-library/utility-operators.md#op_gt_eq)|Tests if the pair object on the left side of the operator is less than or equal to the pair object on the right side.| |
69 |
| -|[operator>](../standard-library/utility-operators.md#op_gt)|Tests if the pair object on the left side of the operator is greater than the pair object on the right side.| |
70 |
| -|[operator>=](../standard-library/utility-operators.md#op_gt_eq)|Tests if the pair object on the left side of the operator is greater than or equal to the pair object on the right side.| |
| 61 | +|[`operator!=`](../standard-library/utility-operators.md#op_neq)|Tests if the pair object on the left side of the operator isn't equal to the pair object on the right side.| |
| 62 | +|[`operator==`](../standard-library/utility-operators.md#op_eq_eq)|Tests if the pair object on the left side of the operator is equal to the pair object on the right side.| |
| 63 | +|[`operator<`](../standard-library/utility-operators.md#op_lt)|Tests if the pair object on the left side of the operator is less than the pair object on the right side.| |
| 64 | +|[`operator<=`](../standard-library/utility-operators.md#op_gt_eq)|Tests if the pair object on the left side of the operator is less than or equal to the pair object on the right side.| |
| 65 | +|[`operator>`](../standard-library/utility-operators.md#op_gt)|Tests if the pair object on the left side of the operator is greater than the pair object on the right side.| |
| 66 | +|[`operator>=`](../standard-library/utility-operators.md#op_gt_eq)|Tests if the pair object on the left side of the operator is greater than or equal to the pair object on the right side.| |
71 | 67 |
|
72 | 68 | ### Structs
|
73 | 69 |
|
74 | 70 | |Struct|Description|
|
75 | 71 | |-|-|
|
76 |
| -|[from_chars_result](../standard-library/from-chars-result-structure.md)|A struct used for `from_chars`.| |
77 |
| -|[identity](../standard-library/identity-structure.md)|A struct that provides a type definition as the template parameter.| |
78 |
| -|[in_place_t](../standard-library/in-place-t-struct.md)|Also includes structs `in_place_type_t` and `in_place_index_t`.| |
79 |
| -|[integer_sequence](../standard-library/integer-sequence-class.md)|Represents an integer sequence.| |
80 |
| -|[pair](../standard-library/pair-structure.md)|A type that provides for the ability to treat two objects as a single object.| |
81 |
| -|[piecewise_construct_t](../standard-library/piecewise-construct-t-structure.md)|A type used to keep separate constructor and function overloading.| |
82 |
| -|[to_chars_result](../standard-library/to-chars-result-structure.md)|A struct used for `to_chars`.| |
| 72 | +|[`from_chars_result`](../standard-library/from-chars-result-structure.md)|A struct used for `from_chars`.| |
| 73 | +|[`identity`](../standard-library/identity-structure.md)|A struct that provides a type definition as the template parameter.| |
| 74 | +|[`in_place_t`, `in_place_type_t`, `in_place_index_t`](../standard-library/in-place-t-struct.md)| Indicates how to create an object in place.| |
| 75 | +|[`integer_sequence`](../standard-library/integer-sequence-class.md)|Represents an integer sequence.| |
| 76 | +|[`pair`](../standard-library/pair-structure.md)|A type that provides for the ability to treat two objects as a single object.| |
| 77 | +|[`piecewise_construct_t`](../standard-library/piecewise-construct-t-structure.md)|A type used to keep separate constructor and function overloading.| |
| 78 | +|[`to_chars_result`](../standard-library/to-chars-result-structure.md)|A struct used for `to_chars`.| |
83 | 79 |
|
84 | 80 | ## See also
|
85 | 81 |
|
|
0 commit comments