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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Constructors <a id="variant.ctor">[[variant.ctor]]</a>
|
| 2 |
+
|
| 3 |
+
In the descriptions that follow, let i be in the range \[`0`,
|
| 4 |
+
`sizeof...(Types)`), and `Tᵢ` be the iᵗʰ type in `Types...`.
|
| 5 |
+
|
| 6 |
+
``` cpp
|
| 7 |
+
constexpr variant() noexcept(see below);
|
| 8 |
+
```
|
| 9 |
+
|
| 10 |
+
*Effects:* Constructs a `variant` holding a value-initialized value of
|
| 11 |
+
type `T₀`.
|
| 12 |
+
|
| 13 |
+
*Postconditions:* `valueless_by_exception()` is `false` and `index()` is
|
| 14 |
+
`0`.
|
| 15 |
+
|
| 16 |
+
*Throws:* Any exception thrown by the value-initialization of `T₀`.
|
| 17 |
+
|
| 18 |
+
*Remarks:* This function shall be `constexpr` if and only if the
|
| 19 |
+
value-initialization of the alternative type `T₀` would satisfy the
|
| 20 |
+
requirements for a constexpr function. The expression inside `noexcept`
|
| 21 |
+
is equivalent to `is_nothrow_default_constructible_v<``T₀``>`. This
|
| 22 |
+
function shall not participate in overload resolution unless
|
| 23 |
+
`is_default_constructible_v<``T₀``>` is `true`.
|
| 24 |
+
|
| 25 |
+
[*Note 1*: See also class `monostate`. — *end note*]
|
| 26 |
+
|
| 27 |
+
``` cpp
|
| 28 |
+
variant(const variant& w);
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
*Effects:* If `w` holds a value, initializes the `variant` to hold the
|
| 32 |
+
same alternative as `w` and direct-initializes the contained value with
|
| 33 |
+
`get<j>(w)`, where `j` is `w.index()`. Otherwise, initializes the
|
| 34 |
+
`variant` to not hold a value.
|
| 35 |
+
|
| 36 |
+
*Throws:* Any exception thrown by direct-initializing any `Tᵢ` for all
|
| 37 |
+
i.
|
| 38 |
+
|
| 39 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 40 |
+
unless `is_copy_constructible_v<``Tᵢ``>` is `true` for all i.
|
| 41 |
+
|
| 42 |
+
``` cpp
|
| 43 |
+
variant(variant&& w) noexcept(see below);
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
*Effects:* If `w` holds a value, initializes the `variant` to hold the
|
| 47 |
+
same alternative as `w` and direct-initializes the contained value with
|
| 48 |
+
`get<j>(std::move(w))`, where `j` is `w.index()`. Otherwise, initializes
|
| 49 |
+
the `variant` to not hold a value.
|
| 50 |
+
|
| 51 |
+
*Throws:* Any exception thrown by move-constructing any `Tᵢ` for all i.
|
| 52 |
+
|
| 53 |
+
*Remarks:* The expression inside `noexcept` is equivalent to the logical
|
| 54 |
+
AND of `is_nothrow_move_constructible_v<``Tᵢ``>` for all i. This
|
| 55 |
+
function shall not participate in overload resolution unless
|
| 56 |
+
`is_move_constructible_v<``Tᵢ``>` is `true` for all i.
|
| 57 |
+
|
| 58 |
+
``` cpp
|
| 59 |
+
template <class T> constexpr variant(T&& t) noexcept(see below);
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
Let `Tⱼ` be a type that is determined as follows: build an imaginary
|
| 63 |
+
function *FUN*(Tᵢ) for each alternative type `Tᵢ`. The overload
|
| 64 |
+
*FUN*(Tⱼ) selected by overload resolution for the expression
|
| 65 |
+
*FUN*(std::forward\<T\>(t)) defines the alternative `Tⱼ` which is the
|
| 66 |
+
type of the contained value after construction.
|
| 67 |
+
|
| 68 |
+
*Effects:* Initializes `*this` to hold the alternative type `Tⱼ` and
|
| 69 |
+
direct-initializes the contained value as if
|
| 70 |
+
direct-non-list-initializing it with `std::forward<T>(t)`.
|
| 71 |
+
|
| 72 |
+
*Postconditions:* `holds_alternative<``Tⱼ``>(*this)` is `true`.
|
| 73 |
+
|
| 74 |
+
*Throws:* Any exception thrown by the initialization of the selected
|
| 75 |
+
alternative `Tⱼ`.
|
| 76 |
+
|
| 77 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 78 |
+
unless `is_same_v<decay_t<T>, variant>` is `false`, unless `decay_t<T>`
|
| 79 |
+
is neither a specialization of `in_place_type_t` nor a specialization of
|
| 80 |
+
`in_place_index_t`, unless `is_constructible_v<``Tⱼ``, T>` is `true`,
|
| 81 |
+
and unless the expression *FUN*(`std::forward<T>(t))` (with *FUN* being
|
| 82 |
+
the above-mentioned set of imaginary functions) is well formed.
|
| 83 |
+
|
| 84 |
+
[*Note 2*:
|
| 85 |
+
|
| 86 |
+
``` cpp
|
| 87 |
+
variant<string, string> v("abc");
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
is ill-formed, as both alternative types have an equally viable
|
| 91 |
+
constructor for the argument.
|
| 92 |
+
|
| 93 |
+
— *end note*]
|
| 94 |
+
|
| 95 |
+
The expression inside `noexcept` is equivalent to
|
| 96 |
+
`is_nothrow_constructible_v<``Tⱼ``, T>`. If `Tⱼ`’s selected constructor
|
| 97 |
+
is a constexpr constructor, this constructor shall be a constexpr
|
| 98 |
+
constructor.
|
| 99 |
+
|
| 100 |
+
``` cpp
|
| 101 |
+
template <class T, class... Args> constexpr explicit variant(in_place_type_t<T>, Args&&... args);
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
*Effects:* Initializes the contained value as if
|
| 105 |
+
direct-non-list-initializing an object of type `T` with the arguments
|
| 106 |
+
`std::forward<Args>(args)...`.
|
| 107 |
+
|
| 108 |
+
*Postconditions:* `holds_alternative<T>(*this)` is `true`.
|
| 109 |
+
|
| 110 |
+
*Throws:* Any exception thrown by calling the selected constructor of
|
| 111 |
+
`T`.
|
| 112 |
+
|
| 113 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 114 |
+
unless there is exactly one occurrence of `T` in `Types...` and
|
| 115 |
+
`is_constructible_v<T, Args...>` is `true`. If `T`’s selected
|
| 116 |
+
constructor is a constexpr constructor, this constructor shall be a
|
| 117 |
+
constexpr constructor.
|
| 118 |
+
|
| 119 |
+
``` cpp
|
| 120 |
+
template <class T, class U, class... Args>
|
| 121 |
+
constexpr explicit variant(in_place_type_t<T>, initializer_list<U> il, Args&&... args);
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
*Effects:* Initializes the contained value as if
|
| 125 |
+
direct-non-list-initializing an object of type `T` with the arguments
|
| 126 |
+
`il, std::forward<Args>(args)...`.
|
| 127 |
+
|
| 128 |
+
*Postconditions:* `holds_alternative<T>(*this)` is `true`.
|
| 129 |
+
|
| 130 |
+
*Throws:* Any exception thrown by calling the selected constructor of
|
| 131 |
+
`T`.
|
| 132 |
+
|
| 133 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 134 |
+
unless there is exactly one occurrence of `T` in `Types...` and
|
| 135 |
+
`is_constructible_v<T, initializer_list<U>&, Args...>` is `true`. If
|
| 136 |
+
`T`’s selected constructor is a constexpr constructor, this constructor
|
| 137 |
+
shall be a constexpr constructor.
|
| 138 |
+
|
| 139 |
+
``` cpp
|
| 140 |
+
template <size_t I, class... Args> constexpr explicit variant(in_place_index_t<I>, Args&&... args);
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
*Effects:* Initializes the contained value as if
|
| 144 |
+
direct-non-list-initializing an object of type `T_I` with the arguments
|
| 145 |
+
`std::forward<Args>(args)...`.
|
| 146 |
+
|
| 147 |
+
*Postconditions:* `index()` is `I`.
|
| 148 |
+
|
| 149 |
+
*Throws:* Any exception thrown by calling the selected constructor of
|
| 150 |
+
`T_I`.
|
| 151 |
+
|
| 152 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 153 |
+
unless
|
| 154 |
+
|
| 155 |
+
- `I` is less than `sizeof...(Types)` and
|
| 156 |
+
- `is_constructible_v<``T_I``, Args...>` is `true`.
|
| 157 |
+
|
| 158 |
+
If `T_I`’s selected constructor is a constexpr constructor, this
|
| 159 |
+
constructor shall be a constexpr constructor.
|
| 160 |
+
|
| 161 |
+
``` cpp
|
| 162 |
+
template <size_t I, class U, class... Args>
|
| 163 |
+
constexpr explicit variant(in_place_index_t<I>, initializer_list<U> il, Args&&... args);
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
*Effects:* Initializes the contained value as if
|
| 167 |
+
direct-non-list-initializing an object of type `T_I` with the arguments
|
| 168 |
+
`il, std::forward<Args>(args)...`.
|
| 169 |
+
|
| 170 |
+
*Postconditions:* `index()` is `I`.
|
| 171 |
+
|
| 172 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 173 |
+
unless
|
| 174 |
+
|
| 175 |
+
- `I` is less than `sizeof...(Types)` and
|
| 176 |
+
- `is_constructible_v<``T_I``, initializer_list<U>&, Args...>` is
|
| 177 |
+
`true`.
|
| 178 |
+
|
| 179 |
+
If `T_I`’s selected constructor is a constexpr constructor, this
|
| 180 |
+
constructor shall be a constexpr constructor.
|
| 181 |
+
|
| 182 |
+
``` cpp
|
| 183 |
+
// allocator-extended constructors
|
| 184 |
+
template <class Alloc>
|
| 185 |
+
variant(allocator_arg_t, const Alloc& a);
|
| 186 |
+
template <class Alloc>
|
| 187 |
+
variant(allocator_arg_t, const Alloc& a, const variant& v);
|
| 188 |
+
template <class Alloc>
|
| 189 |
+
variant(allocator_arg_t, const Alloc& a, variant&& v);
|
| 190 |
+
template <class Alloc, class T>
|
| 191 |
+
variant(allocator_arg_t, const Alloc& a, T&& t);
|
| 192 |
+
template <class Alloc, class T, class... Args>
|
| 193 |
+
variant(allocator_arg_t, const Alloc& a, in_place_type_t<T>, Args&&... args);
|
| 194 |
+
template <class Alloc, class T, class U, class... Args>
|
| 195 |
+
variant(allocator_arg_t, const Alloc& a, in_place_type_t<T>,
|
| 196 |
+
initializer_list<U> il, Args&&... args);
|
| 197 |
+
template <class Alloc, size_t I, class... Args>
|
| 198 |
+
variant(allocator_arg_t, const Alloc& a, in_place_index_t<I>, Args&&... args);
|
| 199 |
+
template <class Alloc, size_t I, class U, class... Args>
|
| 200 |
+
variant(allocator_arg_t, const Alloc& a, in_place_index_t<I>,
|
| 201 |
+
initializer_list<U> il, Args&&... args);
|
| 202 |
+
```
|
| 203 |
+
|
| 204 |
+
*Requires:* `Alloc` shall meet the requirements for an
|
| 205 |
+
Allocator ([[allocator.requirements]]).
|
| 206 |
+
|
| 207 |
+
*Effects:* Equivalent to the preceding constructors except that the
|
| 208 |
+
contained value is constructed with uses-allocator
|
| 209 |
+
construction ([[allocator.uses.construction]]).
|
| 210 |
+
|