From 9fca3a38addf89cc1c73e772a9a751dc7e0daa19 Mon Sep 17 00:00:00 2001 From: TylerMSFT Date: Wed, 13 Nov 2024 18:49:19 -0800 Subject: [PATCH 01/16] add missing in_place* types --- docs/standard-library/in-place-t-struct.md | 110 ++++++++++++++++++--- docs/standard-library/optional-class.md | 2 +- docs/standard-library/toc.yml | 2 + docs/standard-library/utility.md | 71 +++++++------ 4 files changed, 133 insertions(+), 52 deletions(-) diff --git a/docs/standard-library/in-place-t-struct.md b/docs/standard-library/in-place-t-struct.md index 4e2312570f..981fbee617 100644 --- a/docs/standard-library/in-place-t-struct.md +++ b/docs/standard-library/in-place-t-struct.md @@ -1,32 +1,112 @@ --- -description: "Learn more about: in_place_t Struct" -title: "in_place_t Struct" -ms.date: "11/04/2016" -f1_keywords: ["utility", "utility/std::in_place_t"] -helpviewer_keywords: ["utility struct"] +description: "Learn more about: in_place_t, in_place_type_t, in_place_index_t" +title: "in_place_t, in_place_type_t, in_place_index_t" +ms.date: 11/13/2024 +f1_keywords: ["utility/utility", "utility/std::in_place_t", "utility/utility", "utility/std::in_place_type_t", "utility", "utility/std::in_place_index_t"] +helpviewer_keywords: ["utility struct", "utility struct", "utility::in_place_type_t struct", "utility struct", "utility::in_place_index_t struct"] --- -# in_place_t Struct +# `in_place_t`, `in_place_type_t`, `in_place_index_t` struct + +Introduced in C++17. + +The `in_place_t`, `in_place_type_t`, and `in_place_index_t` types are used in some constructors to indicate how to create the object in place. This helps avoid temporary copy or move operations. ## Syntax ```cpp -struct in_place_t { +struct in_place_t +{ explicit in_place_t() = default; }; inline constexpr in_place_t in_place{}; template - struct in_place_type_t { - explicit in_place_type_t() = default; - }; +struct in_place_type_t +{ + explicit in_place_type_t() = default; +}; + +template +inline constexpr in_place_type_t in_place_type{}; -template inline constexpr in_place_type_t in_place_type{}; +template +struct in_place_index_t +{ + explicit in_place_index_t() = default; +}; template - struct in_place_index_t { - explicit in_place_index_t() = default; - }; +inline constexpr in_place_index_t in_place_index{}; +``` + +## Requirements + +**Header:** `` + +**Namespace:** `` + +**Compiler Option:** [`/std:c++17`](../build/reference/std-specify-language-standard-version.md) or later. + + +## Parameters + +*I*\ +The index where the object will be created in place. + +*T*\ +The type of object to create in place. + +## Remarks + +- `in_place_t` indicates in-place construction of an object. +- `in_place_type_t` indicates in-place construction of an object of a specific type. +- `in_place_index_t` indicates in-place construction of an object at a specific index. + +The following are some types that use these structs in their constructors: `expected` class, [`optional` class](optional-class.md), [`single_view` class](single-view-class.md), [`any` class](any-class.md) or [`variant` class](variant-class.md). + +## Example + +```cpp +#include +#include +#include +#include + +// compile with /std:c++17 + +struct MyStruct +{ + int value; + MyStruct(int v) : value(v) + { + } +}; + +int main() +{ + // Uses std::in_place to construct an integer directly inside opt + std::optional opt(std::in_place, MyStruct(42)); + + // Construct a MyStruct object inside various objects + std::any a(std::in_place_type, MyStruct(314)); + + // Construct a MyStruct object inside a vector object at index 0 + std::variant v(std::in_place_index<0>, MyStruct(271)); + + + if (opt) + { + std::cout << opt->value << ", "; + } + + std::cout << std::any_cast(a).value << ", " + << std::get<0>(v).value << std::endl; + + return 0; +} +``` -template inline constexpr in_place_index_t in_place_index{}; +```output +42, 314, 271 ``` diff --git a/docs/standard-library/optional-class.md b/docs/standard-library/optional-class.md index 91889ce7f7..89d4b600f5 100644 --- a/docs/standard-library/optional-class.md +++ b/docs/standard-library/optional-class.md @@ -11,7 +11,7 @@ The class template `optional` describes an object that may or may not contain When an instance of `optional` contains a value, the contained value is allocated within the storage of the `optional` object, in a region suitably aligned for type `T`. When an `optional` is converted to **`bool`**, the result is **`true`** if the object contains a value; otherwise, it's **`false`**. -The contained object type `T` must not be [in_place_t](in-place-t-struct.md) or [nullopt_t](nullopt-t-structure.md). `T` must be *destructible*, that is, its destructor must reclaim all owned resources, and may throw no exceptions. +The contained object type `T` must not be [`in_place_t`](in-place-t-struct.md) or [`nullopt_t`](nullopt-t-structure.md). `T` must be *destructible*, that is, its destructor must reclaim all owned resources, and may throw no exceptions. The `optional` class is new in C++17. diff --git a/docs/standard-library/toc.yml b/docs/standard-library/toc.yml index 12935fdd96..cc264178c1 100644 --- a/docs/standard-library/toc.yml +++ b/docs/standard-library/toc.yml @@ -1447,6 +1447,8 @@ items: href: utility-operators.md - name: identity struct href: identity-structure.md + - name: in_plact_t in_place_type_t, in_place_index_t struct + href: in-place-t-struct.md - name: pair struct href: pair-structure.md - name: diff --git a/docs/standard-library/utility.md b/docs/standard-library/utility.md index 253764a553..5e2f4c3bf5 100644 --- a/docs/standard-library/utility.md +++ b/docs/standard-library/utility.md @@ -4,7 +4,6 @@ title: "" ms.date: "11/04/2016" f1_keywords: [""] helpviewer_keywords: ["utility header"] -ms.assetid: c4491103-5da9-47a1-9c2b-ed8bc64b0599 --- # `` @@ -12,16 +11,16 @@ Defines C++ Standard Library types, functions, and operators that help to constr ## Requirements -**Header:** \ +**Header:** `` -**Namespace:** std +**Namespace:** `std` ## Remarks -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 \ header is automatically included by \ to assist in managing their key/value pair type elements. +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 `` header is automatically included by `` to assist in managing their key/value pair type elements. > [!NOTE] -> The \ header uses the statement `#include `. It also refers to `class tuple` as defined in \. +> The `` header uses the statement `#include `. It also refers to `class tuple` as defined in ``. ## Members @@ -29,57 +28,57 @@ Pairs are widely used in the C++ Standard Library. They are required both as the |Type|Description| |-|-| -|[chars_format](../standard-library/chars-format-class.md)|Floating-point format for primitive numerical conversion.| -|[tuple_element](../standard-library/tuple-element-class-tuple.md)|A class that wraps the type of a `pair` element.| -|[tuple_size](../standard-library/tuple-size-class-tuple.md)|A class that wraps `pair` element count.| +|[`chars_format`](../standard-library/chars-format-class.md)|Floating-point format for primitive numerical conversion.| +|[`tuple_element`](../standard-library/tuple-element-class-tuple.md)|A class that wraps the type of a `pair` element.| +|[`tuple_size`](../standard-library/tuple-size-class-tuple.md)|A class that wraps `pair` element count.| ### Objects |Template|Description| |-|-| -|[index_sequence](../standard-library/utility-functions.md#index_sequence)|An alias template defined for the common case where `T` is `std::size_t` | -|[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| -|[make_index_sequence](../standard-library/utility-functions.md#make_index_sequence)| Helper alias template to simplify the creation of a `std::index_sequence` type. | -|[make_integer_sequence](../standard-library/utility-functions.md#make_integer_sequence)|Helper alias template to simplify the creation of a `std::integer_sequence` type.| +|[`index_sequence`](../standard-library/utility-functions.md#index_sequence)|An alias template defined for the common case where `T` is `std::size_t` | +|[`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| +|[`make_index_sequence`](../standard-library/utility-functions.md#make_index_sequence)| Helper alias template to simplify the creation of a `std::index_sequence` type. | +|[`make_integer_sequence`](../standard-library/utility-functions.md#make_integer_sequence)|Helper alias template to simplify the creation of a `std::integer_sequence` type.| ### Functions |Function|Description| |-|-| -|[as_const](../standard-library/utility-functions.md#asconst)|Returns type.| -|[declval](../standard-library/utility-functions.md#declval)|Shorthand expression evaluation.| -|[exchange](../standard-library/utility-functions.md#exchange)|Assigns a new value to an object and returns its old value.| -|[forward](../standard-library/utility-functions.md#forward)|Preserves the reference type (either `lvalue` or `rvalue`) of the argument from being obscured by perfect forwarding.| -|[from_chars](../standard-library/utility-functions.md#from_chars)|| -|[get](../standard-library/utility-functions.md#get)|A function that gets an element from a `pair` object.| -|[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.| -|[move](../standard-library/utility-functions.md#move)|Returns the passed in argument as an `rvalue` reference.| -|[move_if_noexcept](../standard-library/utility-functions.md#moveif)|| -|[swap](../standard-library/utility-functions.md#swap)|Exchanges the elements of two `pair` objects.| -|[to_chars](../standard-library/utility-functions.md#to_chars)|Converts value into a character string.| +|[`as_const`](../standard-library/utility-functions.md#asconst)|Returns type.| +|[`declval`](../standard-library/utility-functions.md#declval)|Shorthand expression evaluation.| +|[`exchange`](../standard-library/utility-functions.md#exchange)|Assigns a new value to an object and returns its old value.| +|[`forward`](../standard-library/utility-functions.md#forward)|Preserves the reference type (either `lvalue` or `rvalue`) of the argument from being obscured by perfect forwarding.| +|[`from_chars`](../standard-library/utility-functions.md#from_chars)|| +|[`get`](../standard-library/utility-functions.md#get)|A function that gets an element from a `pair` object.| +|[`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.| +|[`move`](../standard-library/utility-functions.md#move)|Returns the passed in argument as an `rvalue` reference.| +|[`move_if_noexcept`](../standard-library/utility-functions.md#moveif)|| +|[`swap`](../standard-library/utility-functions.md#swap)|Exchanges the elements of two `pair` objects.| +|[`to_chars`](../standard-library/utility-functions.md#to_chars)|Converts value into a character string.| ### Operators |Operator|Description| |-|-| -|[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.| -|[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.| -|[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.| -|[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.| -|[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.| -|[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.| +|[`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.| +|[`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.| +|[`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.| +|[`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.| +|[`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.| +|[`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.| ### Structs |Struct|Description| |-|-| -|[from_chars_result](../standard-library/from-chars-result-structure.md)|A struct used for `from_chars`.| -|[identity](../standard-library/identity-structure.md)|A struct that provides a type definition as the template parameter.| -|[in_place_t](../standard-library/in-place-t-struct.md)|Also includes structs `in_place_type_t` and `in_place_index_t`.| -|[integer_sequence](../standard-library/integer-sequence-class.md)|Represents an integer sequence.| -|[pair](../standard-library/pair-structure.md)|A type that provides for the ability to treat two objects as a single object.| -|[piecewise_construct_t](../standard-library/piecewise-construct-t-structure.md)|A type used to keep separate constructor and function overloading.| -|[to_chars_result](../standard-library/to-chars-result-structure.md)|A struct used for `to_chars`.| +|[`from_chars_result`](../standard-library/from-chars-result-structure.md)|A struct used for `from_chars`.| +|[`identity`](../standard-library/identity-structure.md)|A struct that provides a type definition as the template parameter.| +|[`in_place_t`, `in_place_type_t`, `in_place_index_t`](../standard-library/in-place-t-struct.md)| Indicates how to create the in-place object.| +|[`integer_sequence`](../standard-library/integer-sequence-class.md)|Represents an integer sequence.| +|[`pair`](../standard-library/pair-structure.md)|A type that provides for the ability to treat two objects as a single object.| +|[`piecewise_construct_t`](../standard-library/piecewise-construct-t-structure.md)|A type used to keep separate constructor and function overloading.| +|[`to_chars_result`](../standard-library/to-chars-result-structure.md)|A struct used for `to_chars`.| ## See also From 591a7d7e623da6f7d7da2c27bccc423be4a74c14 Mon Sep 17 00:00:00 2001 From: TylerMSFT Date: Thu, 14 Nov 2024 10:42:07 -0800 Subject: [PATCH 02/16] acrolinx --- docs/standard-library/in-place-t-struct.md | 44 ++++++++++------------ docs/standard-library/optional-class.md | 2 +- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/docs/standard-library/in-place-t-struct.md b/docs/standard-library/in-place-t-struct.md index 981fbee617..9614c63be0 100644 --- a/docs/standard-library/in-place-t-struct.md +++ b/docs/standard-library/in-place-t-struct.md @@ -4,6 +4,7 @@ title: "in_place_t, in_place_type_t, in_place_index_t" ms.date: 11/13/2024 f1_keywords: ["utility/utility", "utility/std::in_place_t", "utility/utility", "utility/std::in_place_type_t", "utility", "utility/std::in_place_index_t"] helpviewer_keywords: ["utility struct", "utility struct", "utility::in_place_type_t struct", "utility struct", "utility::in_place_index_t struct"] +ai-usage: ai-assisted --- # `in_place_t`, `in_place_type_t`, `in_place_index_t` struct @@ -40,28 +41,19 @@ template inline constexpr in_place_index_t in_place_index{}; ``` -## Requirements - -**Header:** `` - -**Namespace:** `` - -**Compiler Option:** [`/std:c++17`](../build/reference/std-specify-language-standard-version.md) or later. - - ## Parameters -*I*\ -The index where the object will be created in place. +*`I`*\ +The index where the object is created in place. -*T*\ -The type of object to create in place. +*`T`*\ +The type of object to create. ## Remarks -- `in_place_t` indicates in-place construction of an object. -- `in_place_type_t` indicates in-place construction of an object of a specific type. -- `in_place_index_t` indicates in-place construction of an object at a specific index. +- `in_place_t` indicates in-place construction of an object. Use this to create objects in place inside a `std::optional` or `std::variant`. +- `in_place_type_t` indicates in-place construction of an object of a specific type. This is useful with `std::any` because `std::any` can hold any kind of type, so we need to specify the type it will hold. +- `in_place_index_t` indicates in-place construction of an object at a specific index. Use this with `std::variant` to specify the index where the object is created. The following are some types that use these structs in their constructors: `expected` class, [`optional` class](optional-class.md), [`single_view` class](single-view-class.md), [`any` class](any-class.md) or [`variant` class](variant-class.md). @@ -78,30 +70,27 @@ The following are some types that use these structs in their constructors: `expe struct MyStruct { int value; - MyStruct(int v) : value(v) - { - } + MyStruct(int v) : value(v) {} }; int main() { - // Uses std::in_place to construct an integer directly inside opt + // Construct a MyStruct directly inside opt std::optional opt(std::in_place, MyStruct(42)); - // Construct a MyStruct object inside various objects + // Construct a MyStruct object inside an any object std::any a(std::in_place_type, MyStruct(314)); - // Construct a MyStruct object inside a vector object at index 0 + // Construct a MyStruct object inside a vector at index 0 std::variant v(std::in_place_index<0>, MyStruct(271)); - if (opt) { std::cout << opt->value << ", "; } std::cout << std::any_cast(a).value << ", " - << std::get<0>(v).value << std::endl; + << std::get<0>(v).value; return 0; } @@ -110,3 +99,10 @@ int main() ```output 42, 314, 271 ``` +## Requirements + +**Header:** `` + +**Namespace:** `` + +**Compiler Option:** [`/std:c++17`](../build/reference/std-specify-language-standard-version.md) or later. \ No newline at end of file diff --git a/docs/standard-library/optional-class.md b/docs/standard-library/optional-class.md index 89d4b600f5..e89950d8b0 100644 --- a/docs/standard-library/optional-class.md +++ b/docs/standard-library/optional-class.md @@ -123,7 +123,7 @@ If *rhs* contains a value, direct initializes the contained value as if using `s ## ~optional destructor -Destroys any non-trivially destructible contained value, if one is present, by invoking its destructor. +Destroys any nontrivially destructible contained value, if one is present, by invoking its destructor. ```cpp ~optional(); From 72255c7c393a32fa460bf457da8969530189daf1 Mon Sep 17 00:00:00 2001 From: Tyler Whitney Date: Thu, 14 Nov 2024 14:16:27 -0800 Subject: [PATCH 03/16] Update docs/standard-library/in-place-t-struct.md Co-authored-by: Casey Carter --- docs/standard-library/in-place-t-struct.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard-library/in-place-t-struct.md b/docs/standard-library/in-place-t-struct.md index 9614c63be0..84e031ca4b 100644 --- a/docs/standard-library/in-place-t-struct.md +++ b/docs/standard-library/in-place-t-struct.md @@ -51,7 +51,7 @@ The type of object to create. ## Remarks -- `in_place_t` indicates in-place construction of an object. Use this to create objects in place inside a `std::optional` or `std::variant`. +- `in_place_t` indicates in-place construction of an object. Use this to create objects in place inside a `std::optional`. - `in_place_type_t` indicates in-place construction of an object of a specific type. This is useful with `std::any` because `std::any` can hold any kind of type, so we need to specify the type it will hold. - `in_place_index_t` indicates in-place construction of an object at a specific index. Use this with `std::variant` to specify the index where the object is created. From 65e86d040dda42526ea92b699e02804abb4c943f Mon Sep 17 00:00:00 2001 From: Tyler Whitney Date: Thu, 14 Nov 2024 14:21:57 -0800 Subject: [PATCH 04/16] Update docs/standard-library/in-place-t-struct.md Co-authored-by: Casey Carter --- docs/standard-library/in-place-t-struct.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard-library/in-place-t-struct.md b/docs/standard-library/in-place-t-struct.md index 84e031ca4b..04f7e9e4a5 100644 --- a/docs/standard-library/in-place-t-struct.md +++ b/docs/standard-library/in-place-t-struct.md @@ -76,7 +76,7 @@ struct MyStruct int main() { // Construct a MyStruct directly inside opt - std::optional opt(std::in_place, MyStruct(42)); + std::optional opt(std::in_place, 42); // Construct a MyStruct object inside an any object std::any a(std::in_place_type, MyStruct(314)); From e40161ad7a3a2da5543cfd63649cbc1f8442a31a Mon Sep 17 00:00:00 2001 From: Tyler Whitney Date: Thu, 14 Nov 2024 14:22:15 -0800 Subject: [PATCH 05/16] Update docs/standard-library/in-place-t-struct.md Co-authored-by: Casey Carter --- docs/standard-library/in-place-t-struct.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard-library/in-place-t-struct.md b/docs/standard-library/in-place-t-struct.md index 04f7e9e4a5..afc3f1ee89 100644 --- a/docs/standard-library/in-place-t-struct.md +++ b/docs/standard-library/in-place-t-struct.md @@ -79,7 +79,7 @@ int main() std::optional opt(std::in_place, 42); // Construct a MyStruct object inside an any object - std::any a(std::in_place_type, MyStruct(314)); + std::any a(std::in_place_type, 314); // Construct a MyStruct object inside a vector at index 0 std::variant v(std::in_place_index<0>, MyStruct(271)); From 2ee9a9443f4325416deecb2bd226e1bafbefe402 Mon Sep 17 00:00:00 2001 From: Tyler Whitney Date: Thu, 14 Nov 2024 14:22:45 -0800 Subject: [PATCH 06/16] Update docs/standard-library/in-place-t-struct.md Co-authored-by: Casey Carter --- docs/standard-library/in-place-t-struct.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard-library/in-place-t-struct.md b/docs/standard-library/in-place-t-struct.md index afc3f1ee89..6e876d64c3 100644 --- a/docs/standard-library/in-place-t-struct.md +++ b/docs/standard-library/in-place-t-struct.md @@ -82,7 +82,7 @@ int main() std::any a(std::in_place_type, 314); // Construct a MyStruct object inside a vector at index 0 - std::variant v(std::in_place_index<0>, MyStruct(271)); + std::variant v(std::in_place_index<0>, 271); if (opt) { From 2af1d2f7958c7f6a09540ef68f47a29f6edb41b9 Mon Sep 17 00:00:00 2001 From: Tyler Whitney Date: Thu, 14 Nov 2024 14:23:07 -0800 Subject: [PATCH 07/16] Update docs/standard-library/in-place-t-struct.md Co-authored-by: Casey Carter --- docs/standard-library/in-place-t-struct.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard-library/in-place-t-struct.md b/docs/standard-library/in-place-t-struct.md index 6e876d64c3..b55371cbea 100644 --- a/docs/standard-library/in-place-t-struct.md +++ b/docs/standard-library/in-place-t-struct.md @@ -103,6 +103,6 @@ int main() **Header:** `` -**Namespace:** `` +**Namespace:** `std` **Compiler Option:** [`/std:c++17`](../build/reference/std-specify-language-standard-version.md) or later. \ No newline at end of file From 1031d5cfc45ef90c6bef6ab331e2566f054c17b3 Mon Sep 17 00:00:00 2001 From: Tyler Whitney Date: Thu, 14 Nov 2024 14:24:57 -0800 Subject: [PATCH 08/16] Update docs/standard-library/toc.yml Co-authored-by: Casey Carter --- docs/standard-library/toc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard-library/toc.yml b/docs/standard-library/toc.yml index cc264178c1..43e6cbcb4e 100644 --- a/docs/standard-library/toc.yml +++ b/docs/standard-library/toc.yml @@ -1447,7 +1447,7 @@ items: href: utility-operators.md - name: identity struct href: identity-structure.md - - name: in_plact_t in_place_type_t, in_place_index_t struct + - name: in_place_t, in_place_type_t, in_place_index_t struct href: in-place-t-struct.md - name: pair struct href: pair-structure.md From 7eac890ec0066d8c9c3cf8853b26a544da977522 Mon Sep 17 00:00:00 2001 From: Tyler Whitney Date: Thu, 14 Nov 2024 14:26:48 -0800 Subject: [PATCH 09/16] Update docs/standard-library/utility.md Co-authored-by: Casey Carter --- docs/standard-library/utility.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard-library/utility.md b/docs/standard-library/utility.md index 5e2f4c3bf5..c9845a6c25 100644 --- a/docs/standard-library/utility.md +++ b/docs/standard-library/utility.md @@ -17,7 +17,7 @@ Defines C++ Standard Library types, functions, and operators that help to constr ## Remarks -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 `` header is automatically included by `` to assist in managing their key/value pair type elements. +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 associative containers like [`map` class](../standard-library/map-class.md) and [`multimap` class](../standard-library/multimap-class.md). > [!NOTE] > The `` header uses the statement `#include `. It also refers to `class tuple` as defined in ``. From d1b114e7fca42881c971381dcdf1ba31e8ff2c89 Mon Sep 17 00:00:00 2001 From: Tyler Whitney Date: Thu, 14 Nov 2024 14:28:49 -0800 Subject: [PATCH 10/16] Update docs/standard-library/utility.md Co-authored-by: Casey Carter --- docs/standard-library/utility.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard-library/utility.md b/docs/standard-library/utility.md index c9845a6c25..c14951bf17 100644 --- a/docs/standard-library/utility.md +++ b/docs/standard-library/utility.md @@ -20,7 +20,7 @@ Defines C++ Standard Library types, functions, and operators that help to constr 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 associative containers like [`map` class](../standard-library/map-class.md) and [`multimap` class](../standard-library/multimap-class.md). > [!NOTE] -> The `` header uses the statement `#include `. It also refers to `class tuple` as defined in ``. +> The `` header includes ``. It also refers to `class tuple` as defined in ``. ## Members From 62133120e37792cfdcec1f50800c6364157a71f9 Mon Sep 17 00:00:00 2001 From: Tyler Whitney Date: Thu, 14 Nov 2024 14:29:27 -0800 Subject: [PATCH 11/16] Update docs/standard-library/utility.md Co-authored-by: Casey Carter --- docs/standard-library/utility.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard-library/utility.md b/docs/standard-library/utility.md index c14951bf17..85f0d5e7ae 100644 --- a/docs/standard-library/utility.md +++ b/docs/standard-library/utility.md @@ -74,7 +74,7 @@ Pairs are widely used in the C++ Standard Library. They are required both as the |-|-| |[`from_chars_result`](../standard-library/from-chars-result-structure.md)|A struct used for `from_chars`.| |[`identity`](../standard-library/identity-structure.md)|A struct that provides a type definition as the template parameter.| -|[`in_place_t`, `in_place_type_t`, `in_place_index_t`](../standard-library/in-place-t-struct.md)| Indicates how to create the in-place object.| +|[`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.| |[`integer_sequence`](../standard-library/integer-sequence-class.md)|Represents an integer sequence.| |[`pair`](../standard-library/pair-structure.md)|A type that provides for the ability to treat two objects as a single object.| |[`piecewise_construct_t`](../standard-library/piecewise-construct-t-structure.md)|A type used to keep separate constructor and function overloading.| From 6654c5f952e6ba2944023f326386feaf39784bfb Mon Sep 17 00:00:00 2001 From: TylerMSFT Date: Thu, 14 Nov 2024 14:41:19 -0800 Subject: [PATCH 12/16] tech review --- docs/standard-library/in-place-t-struct.md | 14 +++++++------- docs/standard-library/optional-class.md | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/standard-library/in-place-t-struct.md b/docs/standard-library/in-place-t-struct.md index 9614c63be0..99b1e46f6e 100644 --- a/docs/standard-library/in-place-t-struct.md +++ b/docs/standard-library/in-place-t-struct.md @@ -10,7 +10,7 @@ ai-usage: ai-assisted Introduced in C++17. -The `in_place_t`, `in_place_type_t`, and `in_place_index_t` types are used in some constructors to indicate how to create the object in place. This helps avoid temporary copy or move operations. +The `in_place_t`, `in_place_type_t`, and `in_place_index_t` types are used to select the overloaded constructor that creates the object in place in the desired way. For the types that use these tag types, it can help avoid temporary copy or move operations. ## Syntax @@ -29,7 +29,7 @@ struct in_place_type_t }; template -inline constexpr in_place_type_t in_place_type{}; +constexpr in_place_type_t in_place_type{}; template struct in_place_index_t @@ -38,7 +38,7 @@ struct in_place_index_t }; template -inline constexpr in_place_index_t in_place_index{}; +constexpr in_place_index_t in_place_index{}; ``` ## Parameters @@ -51,11 +51,11 @@ The type of object to create. ## Remarks -- `in_place_t` indicates in-place construction of an object. Use this to create objects in place inside a `std::optional` or `std::variant`. -- `in_place_type_t` indicates in-place construction of an object of a specific type. This is useful with `std::any` because `std::any` can hold any kind of type, so we need to specify the type it will hold. -- `in_place_index_t` indicates in-place construction of an object at a specific index. Use this with `std::variant` to specify the index where the object is created. +- `in_place_t` indicates in-place construction of an object. Use to create objects in place inside a `std::optional` or `std::variant`. +- `in_place_type_t` indicates in-place construction of an object of a specific type. It's useful with `std::any` because `std::any` can hold any kind of type, so we need to specify the type it holds. +- `in_place_index_t` indicates in-place construction of an object at a specific index. Use with `std::variant` to specify the index where the object is created. -The following are some types that use these structs in their constructors: `expected` class, [`optional` class](optional-class.md), [`single_view` class](single-view-class.md), [`any` class](any-class.md) or [`variant` class](variant-class.md). +The following class types use these structs in their constructors: `expected`, [`optional`](optional-class.md), [`single_view`](single-view-class.md), [`any`](any-class.md) or [`variant`](variant-class.md). ## Example diff --git a/docs/standard-library/optional-class.md b/docs/standard-library/optional-class.md index e89950d8b0..a7806c1f47 100644 --- a/docs/standard-library/optional-class.md +++ b/docs/standard-library/optional-class.md @@ -123,7 +123,7 @@ If *rhs* contains a value, direct initializes the contained value as if using `s ## ~optional destructor -Destroys any nontrivially destructible contained value, if one is present, by invoking its destructor. +Destroys the contained value, if one is present. ```cpp ~optional(); From e03f3789493a70469333e5115cab038abd1fdb94 Mon Sep 17 00:00:00 2001 From: TylerMSFT Date: Thu, 14 Nov 2024 16:07:12 -0800 Subject: [PATCH 13/16] update example --- docs/standard-library/in-place-t-struct.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/standard-library/in-place-t-struct.md b/docs/standard-library/in-place-t-struct.md index 0f04faa7ae..7a1cbb032f 100644 --- a/docs/standard-library/in-place-t-struct.md +++ b/docs/standard-library/in-place-t-struct.md @@ -4,7 +4,6 @@ title: "in_place_t, in_place_type_t, in_place_index_t" ms.date: 11/14/2024 f1_keywords: ["utility/utility", "utility/std::in_place_t", "utility/utility", "utility/std::in_place_type_t", "utility", "utility/std::in_place_index_t"] helpviewer_keywords: ["utility struct", "utility struct", "utility::in_place_type_t struct", "utility struct", "utility::in_place_index_t struct"] -ai-usage: ai-assisted --- # `in_place_t`, `in_place_type_t`, `in_place_index_t` struct @@ -69,20 +68,20 @@ The following class types use these structs in their constructors: `expected`, [ struct MyStruct { - int value; - MyStruct(int v) : value(v) {} + double value; + MyStruct(double v0, double v1) : value(v0 + v1) {} }; int main() { // Construct a MyStruct directly inside opt - std::optional opt(std::in_place, 42); + std::optional opt(std::in_place, 29.0, 13.0); // Construct a MyStruct object inside an any object - std::any a(std::in_place_type, 314); - + std::any a(std::in_place_type, 3.0, 0.14); + // Construct a MyStruct object inside a vector at index 0 - std::variant v(std::in_place_index<0>, 271); + std::variant v(std::in_place_index<0>, 2.0, 0.718); if (opt) { @@ -97,7 +96,7 @@ int main() ``` ```output -42, 314, 271 +42, 3.14, 2.718 ``` ## Requirements From 2cb00a333c088a140f95673a2c83b52e2c9ce73c Mon Sep 17 00:00:00 2001 From: TylerMSFT Date: Thu, 14 Nov 2024 16:09:01 -0800 Subject: [PATCH 14/16] updated example --- docs/standard-library/in-place-t-struct.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/standard-library/in-place-t-struct.md b/docs/standard-library/in-place-t-struct.md index 7a1cbb032f..b7c4cecc59 100644 --- a/docs/standard-library/in-place-t-struct.md +++ b/docs/standard-library/in-place-t-struct.md @@ -69,7 +69,7 @@ The following class types use these structs in their constructors: `expected`, [ struct MyStruct { double value; - MyStruct(double v0, double v1) : value(v0 + v1) {} + MyStruct(double v0, double v1 = 0) : value(v0 + v1) {} }; int main() @@ -78,10 +78,10 @@ int main() std::optional opt(std::in_place, 29.0, 13.0); // Construct a MyStruct object inside an any object - std::any a(std::in_place_type, 3.0, 0.14); + std::any a(std::in_place_type, 3.14); // Construct a MyStruct object inside a vector at index 0 - std::variant v(std::in_place_index<0>, 2.0, 0.718); + std::variant v(std::in_place_index<0>, 2.718); if (opt) { From 918f5af5ed7e7cdbf10959b488eba19867ec7e49 Mon Sep 17 00:00:00 2001 From: Mahmoud Saleh <12202790+MahmoudGSaleh@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:05:10 -0800 Subject: [PATCH 15/16] Update latest-supported-vc-redist.md --- docs/windows/latest-supported-vc-redist.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/windows/latest-supported-vc-redist.md b/docs/windows/latest-supported-vc-redist.md index b0bf196730..710fb9a12b 100644 --- a/docs/windows/latest-supported-vc-redist.md +++ b/docs/windows/latest-supported-vc-redist.md @@ -29,7 +29,7 @@ Unlike older versions of Visual Studio, which have infrequent redist updates, th ## Latest Microsoft Visual C++ Redistributable Version -The latest version is `14.40.33816.0` +The latest version is `14.42.34433.0` Use the following links to download this version for each supported architecture: From f78cafcee45acb2a68563772bd46504232dc74b0 Mon Sep 17 00:00:00 2001 From: Tyler Whitney Date: Fri, 15 Nov 2024 10:21:23 -0800 Subject: [PATCH 16/16] Update latest-supported-vc-redist.md --- docs/windows/latest-supported-vc-redist.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/windows/latest-supported-vc-redist.md b/docs/windows/latest-supported-vc-redist.md index 710fb9a12b..840af6a36c 100644 --- a/docs/windows/latest-supported-vc-redist.md +++ b/docs/windows/latest-supported-vc-redist.md @@ -1,7 +1,7 @@ --- title: "Latest supported Visual C++ Redistributable downloads" description: "This article lists the download links for the latest versions of Visual C++ Redistributable packages." -ms.date: 5/28/2024 +ms.date: 11/15/2024 helpviewer_keywords: [ "redist",