You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 591a7d7
Browse filesBrowse the repository at this point in the historyBrowse files
**Compiler Option:**[`/std:c++17`](../build/reference/std-specify-language-standard-version.md) or later.
50
-
51
-
52
44
## Parameters
53
45
54
-
*I*\
55
-
The index where the object will be created in place.
46
+
*`I`*\
47
+
The index where the object is created in place.
56
48
57
-
*T*\
58
-
The type of object to create in place.
49
+
*`T`*\
50
+
The type of object to create.
59
51
60
52
## Remarks
61
53
62
-
-`in_place_t` indicates in-place construction of an object.
63
-
-`in_place_type_t` indicates in-place construction of an object of a specific type.
64
-
-`in_place_index_t` indicates in-place construction of an object at a specific index.
54
+
-`in_place_t` indicates in-place construction of an object. Use this to create objects in place inside a `std::optional` or `std::variant`.
55
+
-`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.
56
+
-`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.
65
57
66
58
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).
67
59
@@ -78,30 +70,27 @@ The following are some types that use these structs in their constructors: `expe
78
70
structMyStruct
79
71
{
80
72
int value;
81
-
MyStruct(int v) : value(v)
82
-
{
83
-
}
73
+
MyStruct(int v) : value(v) {}
84
74
};
85
75
86
76
int main()
87
77
{
88
-
// Uses std::in_place to construct an integer directly inside opt
0 commit comments