@@ -4,7 +4,6 @@ title: "in_place_t, in_place_type_t, in_place_index_t"
44ms.date : 11/14/2024
55f1_keywords : ["utility/utility<in_place_t>", "utility/std::in_place_t", "utility/utility<in_place_type_t>", "utility/std::in_place_type_t", "utility<in_place_index_t>", "utility/std::in_place_index_t"]
66helpviewer_keywords : ["utility<in_place_t> struct", "utility<in_place_type_t> struct", "utility::in_place_type_t struct", "utility<in_place_index_t> struct", "utility::in_place_index_t struct"]
7- ai-usage : ai-assisted
87---
98# ` in_place_t ` , ` in_place_type_t ` , ` in_place_index_t ` struct
109
@@ -69,20 +68,20 @@ The following class types use these structs in their constructors: `expected`, [
6968
7069struct MyStruct
7170{
72- int value;
73- MyStruct (int v ) : value(v ) {}
71+ double value;
72+ MyStruct (double v0, double v1 ) : value(v0 + v1 ) {}
7473};
7574
7675int main()
7776{
7877 // Construct a MyStruct directly inside opt
79- std::optional<MyStruct > opt(std::in_place, 42 );
78+ std::optional<MyStruct > opt(std::in_place, 29.0, 13.0 );
8079
8180 // Construct a MyStruct object inside an any object
82- std::any a(std::in_place_type<MyStruct>, 314 );
83-
81+ std::any a(std::in_place_type<MyStruct>, 3.0, 0.14 );
82+
8483 // Construct a MyStruct object inside a vector at index 0
85- std::variant<MyStruct, int> v(std::in_place_index<0>, 271 );
84+ std::variant<MyStruct, int> v(std::in_place_index<0>, 2.0, 0.718 );
8685
8786 if (opt)
8887 {
@@ -97,7 +96,7 @@ int main()
9796```
9897
9998```output
100- 42, 314, 271
99+ 42, 3.14, 2.718
101100```
102101
103102## Requirements
0 commit comments