tmp/tmpkpzhdkle/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Assignment <a id="variant.assign">[[variant.assign]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
variant& operator=(const variant& rhs);
|
| 5 |
+
```
|
| 6 |
+
|
| 7 |
+
Let j be `rhs.index()`.
|
| 8 |
+
|
| 9 |
+
*Effects:*
|
| 10 |
+
|
| 11 |
+
- If neither `*this` nor `rhs` holds a value, there is no effect.
|
| 12 |
+
Otherwise,
|
| 13 |
+
- if `*this` holds a value but `rhs` does not, destroys the value
|
| 14 |
+
contained in `*this` and sets `*this` to not hold a value. Otherwise,
|
| 15 |
+
- if `index() == `j, assigns the value contained in `rhs` to the value
|
| 16 |
+
contained in `*this`. Otherwise,
|
| 17 |
+
- if either `is_nothrow_copy_constructible_v<``Tⱼ``>` or
|
| 18 |
+
`!is_nothrow_move_constructible_v<``Tⱼ``>` is `true`, equivalent to
|
| 19 |
+
`emplace<`j`>(get<`j`>(rhs))`. Otherwise,
|
| 20 |
+
- equivalent to `operator=(variant(rhs))`.
|
| 21 |
+
|
| 22 |
+
*Returns:* `*this`.
|
| 23 |
+
|
| 24 |
+
*Postconditions:* `index() == rhs.index()`.
|
| 25 |
+
|
| 26 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 27 |
+
unless `is_copy_constructible_v<``Tᵢ``> &&`
|
| 28 |
+
`is_copy_assignable_v<``Tᵢ``>` is `true` for all i.
|
| 29 |
+
|
| 30 |
+
``` cpp
|
| 31 |
+
variant& operator=(variant&& rhs) noexcept(see below);
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
Let j be `rhs.index()`.
|
| 35 |
+
|
| 36 |
+
*Effects:*
|
| 37 |
+
|
| 38 |
+
- If neither `*this` nor `rhs` holds a value, there is no effect.
|
| 39 |
+
Otherwise,
|
| 40 |
+
- if `*this` holds a value but `rhs` does not, destroys the value
|
| 41 |
+
contained in `*this` and sets `*this` to not hold a value. Otherwise,
|
| 42 |
+
- if `index() == `j, assigns `get<`j`>(std::move(rhs))` to the value
|
| 43 |
+
contained in `*this`. Otherwise,
|
| 44 |
+
- equivalent to `emplace<`j`>(get<`j`>(std::move(rhs)))`.
|
| 45 |
+
|
| 46 |
+
*Returns:* `*this`.
|
| 47 |
+
|
| 48 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 49 |
+
unless `is_move_constructible_v<``Tᵢ``> && is_move_assignable_v<``Tᵢ``>`
|
| 50 |
+
is `true` for all i. The expression inside `noexcept` is equivalent to:
|
| 51 |
+
`is_nothrow_move_constructible_v<``Tᵢ``> && is_nothrow_move_assignable_v<``Tᵢ``>`
|
| 52 |
+
for all i.
|
| 53 |
+
|
| 54 |
+
- If an exception is thrown during the call to `Tⱼ`’s move construction
|
| 55 |
+
(with j being `rhs.index())`, the `variant` will hold no value.
|
| 56 |
+
- If an exception is thrown during the call to `Tⱼ`’s move assignment,
|
| 57 |
+
the state of the contained value is as defined by the exception safety
|
| 58 |
+
guarantee of `Tⱼ`’s move assignment; `index()` will be j.
|
| 59 |
+
|
| 60 |
+
``` cpp
|
| 61 |
+
template <class T> variant& operator=(T&& t) noexcept(see below);
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
Let `Tⱼ` be a type that is determined as follows: build an imaginary
|
| 65 |
+
function *FUN*(Tᵢ) for each alternative type `Tᵢ`. The overload
|
| 66 |
+
*FUN*(Tⱼ) selected by overload resolution for the expression
|
| 67 |
+
*FUN*(std::forward\<T\>(t)) defines the alternative `Tⱼ` which is the
|
| 68 |
+
type of the contained value after assignment.
|
| 69 |
+
|
| 70 |
+
*Effects:*
|
| 71 |
+
|
| 72 |
+
- If `*this` holds a `Tⱼ`, assigns `std::forward<T>(t)` to the value
|
| 73 |
+
contained in `*this`. Otherwise,
|
| 74 |
+
- if `is_nothrow_constructible_v<``Tⱼ``, T> ||`
|
| 75 |
+
`!is_nothrow_move_constructible_v<``Tⱼ``>` is `true`, equivalent to
|
| 76 |
+
`emplace<`j`>(std::forward<T>(t))`. Otherwise,
|
| 77 |
+
- equivalent to `operator=(variant(std::forward<T>(t)))`.
|
| 78 |
+
|
| 79 |
+
*Postconditions:* `holds_alternative<``Tⱼ``>(*this)` is `true`, with
|
| 80 |
+
`Tⱼ` selected by the imaginary function overload resolution described
|
| 81 |
+
above.
|
| 82 |
+
|
| 83 |
+
*Returns:* `*this`.
|
| 84 |
+
|
| 85 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 86 |
+
unless `is_same_v<decay_t<T>, variant>` is `false`, unless
|
| 87 |
+
`is_assignable_v<``Tⱼ``&, T> && is_constructible_v<``Tⱼ``, T>` is
|
| 88 |
+
`true`, and unless the expression *FUN*(std::forward\<T\>(t)) (with
|
| 89 |
+
*FUN* being the above-mentioned set of imaginary functions) is well
|
| 90 |
+
formed.
|
| 91 |
+
|
| 92 |
+
[*Note 1*:
|
| 93 |
+
|
| 94 |
+
``` cpp
|
| 95 |
+
variant<string, string> v;
|
| 96 |
+
v = "abc";
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
is ill-formed, as both alternative types have an equally viable
|
| 100 |
+
constructor for the argument.
|
| 101 |
+
|
| 102 |
+
— *end note*]
|
| 103 |
+
|
| 104 |
+
The expression inside `noexcept` is equivalent to:
|
| 105 |
+
|
| 106 |
+
``` cpp
|
| 107 |
+
is_nothrow_assignable_v<Tⱼ&, T> && is_nothrow_constructible_v<Tⱼ, T>
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
- If an exception is thrown during the assignment of
|
| 111 |
+
`std::forward<T>(t)` to the value contained in `*this`, the state of
|
| 112 |
+
the contained value and `t` are as defined by the exception safety
|
| 113 |
+
guarantee of the assignment expression; `valueless_by_exception()`
|
| 114 |
+
will be `false`.
|
| 115 |
+
- If an exception is thrown during the initialization of the contained
|
| 116 |
+
value, the `variant` object might not hold a value.
|
| 117 |
+
|