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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Assignment <a id="expected.object.assign">[[expected.object.assign]]</a>
|
| 2 |
+
|
| 3 |
+
This subclause makes use of the following exposition-only function:
|
| 4 |
+
|
| 5 |
+
``` cpp
|
| 6 |
+
template<class T, class U, class... Args>
|
| 7 |
+
constexpr void reinit-expected(T& newval, U& oldval, Args&&... args) { // exposition only
|
| 8 |
+
if constexpr (is_nothrow_constructible_v<T, Args...>) {
|
| 9 |
+
destroy_at(addressof(oldval));
|
| 10 |
+
construct_at(addressof(newval), std::forward<Args>(args)...);
|
| 11 |
+
} else if constexpr (is_nothrow_move_constructible_v<T>) {
|
| 12 |
+
T tmp(std::forward<Args>(args)...);
|
| 13 |
+
destroy_at(addressof(oldval));
|
| 14 |
+
construct_at(addressof(newval), std::move(tmp));
|
| 15 |
+
} else {
|
| 16 |
+
U tmp(std::move(oldval));
|
| 17 |
+
destroy_at(addressof(oldval));
|
| 18 |
+
try {
|
| 19 |
+
construct_at(addressof(newval), std::forward<Args>(args)...);
|
| 20 |
+
} catch (...) {
|
| 21 |
+
construct_at(addressof(oldval), std::move(tmp));
|
| 22 |
+
throw;
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
``` cpp
|
| 29 |
+
constexpr expected& operator=(const expected& rhs);
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
*Effects:*
|
| 33 |
+
|
| 34 |
+
- If `this->has_value() && rhs.has_value()` is `true`, equivalent to
|
| 35 |
+
*`val`*` = *rhs`.
|
| 36 |
+
- Otherwise, if `this->has_value()` is `true`, equivalent to:
|
| 37 |
+
``` cpp
|
| 38 |
+
reinit-expected(unex, val, rhs.error())
|
| 39 |
+
```
|
| 40 |
+
- Otherwise, if `rhs.has_value()` is `true`, equivalent to:
|
| 41 |
+
``` cpp
|
| 42 |
+
reinit-expected(val, unex, *rhs)
|
| 43 |
+
```
|
| 44 |
+
- Otherwise, equivalent to *`unex`*` = rhs.error()`.
|
| 45 |
+
|
| 46 |
+
Then, if no exception was thrown, equivalent to:
|
| 47 |
+
*`has_val`*` = rhs.has_value(); return *this;`
|
| 48 |
+
|
| 49 |
+
*Returns:* `*this`.
|
| 50 |
+
|
| 51 |
+
*Remarks:* This operator is defined as deleted unless:
|
| 52 |
+
|
| 53 |
+
- `is_copy_assignable_v<T>` is `true` and
|
| 54 |
+
- `is_copy_constructible_v<T>` is `true` and
|
| 55 |
+
- `is_copy_assignable_v<E>` is `true` and
|
| 56 |
+
- `is_copy_constructible_v<E>` is `true` and
|
| 57 |
+
- `is_nothrow_move_constructible_v<T> || is_nothrow_move_constructible_v<E>`
|
| 58 |
+
is `true`.
|
| 59 |
+
|
| 60 |
+
``` cpp
|
| 61 |
+
constexpr expected& operator=(expected&& rhs) noexcept(see below);
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
*Constraints:*
|
| 65 |
+
|
| 66 |
+
- `is_move_constructible_v<T>` is `true` and
|
| 67 |
+
- `is_move_assignable_v<T>` is `true` and
|
| 68 |
+
- `is_move_constructible_v<E>` is `true` and
|
| 69 |
+
- `is_move_assignable_v<E>` is `true` and
|
| 70 |
+
- `is_nothrow_move_constructible_v<T> || is_nothrow_move_constructible_v<E>`
|
| 71 |
+
is `true`.
|
| 72 |
+
|
| 73 |
+
*Effects:*
|
| 74 |
+
|
| 75 |
+
- If `this->has_value() && rhs.has_value()` is `true`, equivalent to
|
| 76 |
+
*`val`*` = std::move(*rhs)`.
|
| 77 |
+
- Otherwise, if `this->has_value()` is `true`, equivalent to:
|
| 78 |
+
``` cpp
|
| 79 |
+
reinit-expected(unex, val, std::move(rhs.error()))
|
| 80 |
+
```
|
| 81 |
+
- Otherwise, if `rhs.has_value()` is `true`, equivalent to:
|
| 82 |
+
``` cpp
|
| 83 |
+
reinit-expected(val, unex, std::move(*rhs))
|
| 84 |
+
```
|
| 85 |
+
- Otherwise, equivalent to *`unex`*` = std::move(rhs.error())`.
|
| 86 |
+
|
| 87 |
+
Then, if no exception was thrown, equivalent to:
|
| 88 |
+
`has_val = rhs.has_value(); return *this;`
|
| 89 |
+
|
| 90 |
+
*Returns:* `*this`.
|
| 91 |
+
|
| 92 |
+
*Remarks:* The exception specification is equivalent to:
|
| 93 |
+
|
| 94 |
+
``` cpp
|
| 95 |
+
is_nothrow_move_assignable_v<T> && is_nothrow_move_constructible_v<T> &&
|
| 96 |
+
is_nothrow_move_assignable_v<E> && is_nothrow_move_constructible_v<E>
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
``` cpp
|
| 100 |
+
template<class U = T>
|
| 101 |
+
constexpr expected& operator=(U&& v);
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
*Constraints:*
|
| 105 |
+
|
| 106 |
+
- `is_same_v<expected, remove_cvref_t<U>>` is `false`; and
|
| 107 |
+
- `remove_cvref_t<U>` is not a specialization of `unexpected`; and
|
| 108 |
+
- `is_constructible_v<T, U>` is `true`; and
|
| 109 |
+
- `is_assignable_v<T&, U>` is `true`; and
|
| 110 |
+
- `is_nothrow_constructible_v<T, U> || is_nothrow_move_constructible_v<T> || is_nothrow_move_constructible_v<E>`
|
| 111 |
+
is `true`.
|
| 112 |
+
|
| 113 |
+
*Effects:*
|
| 114 |
+
|
| 115 |
+
- If `has_value()` is `true`, equivalent to:
|
| 116 |
+
*`val`*` = std::forward<U>(v);`
|
| 117 |
+
- Otherwise, equivalent to:
|
| 118 |
+
``` cpp
|
| 119 |
+
reinit-expected(val, unex, std::forward<U>(v));
|
| 120 |
+
has_val = true;
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
*Returns:* `*this`.
|
| 124 |
+
|
| 125 |
+
``` cpp
|
| 126 |
+
template<class G>
|
| 127 |
+
constexpr expected& operator=(const unexpected<G>& e);
|
| 128 |
+
template<class G>
|
| 129 |
+
constexpr expected& operator=(unexpected<G>&& e);
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
Let `GF` be `const G&` for the first overload and `G` for the second
|
| 133 |
+
overload.
|
| 134 |
+
|
| 135 |
+
*Constraints:*
|
| 136 |
+
|
| 137 |
+
- `is_constructible_v<E, GF>` is `true`; and
|
| 138 |
+
- `is_assignable_v<E&, GF>` is `true`; and
|
| 139 |
+
- `is_nothrow_constructible_v<E, GF> || is_nothrow_move_constructible_v<T> || is_nothrow_move_constructible_v<E>`
|
| 140 |
+
is `true`.
|
| 141 |
+
|
| 142 |
+
*Effects:*
|
| 143 |
+
|
| 144 |
+
- If `has_value()` is `true`, equivalent to:
|
| 145 |
+
``` cpp
|
| 146 |
+
reinit-expected(unex, val, std::forward<GF>(e.error()));
|
| 147 |
+
has_val = false;
|
| 148 |
+
```
|
| 149 |
+
- Otherwise, equivalent to: *`unex`*` = std::forward<GF>(e.error());`
|
| 150 |
+
|
| 151 |
+
*Returns:* `*this`.
|
| 152 |
+
|
| 153 |
+
``` cpp
|
| 154 |
+
template<class... Args>
|
| 155 |
+
constexpr T& emplace(Args&&... args) noexcept;
|
| 156 |
+
```
|
| 157 |
+
|
| 158 |
+
*Constraints:* `is_nothrow_constructible_v<T, Args...>` is `true`.
|
| 159 |
+
|
| 160 |
+
*Effects:* Equivalent to:
|
| 161 |
+
|
| 162 |
+
``` cpp
|
| 163 |
+
if (has_value()) {
|
| 164 |
+
destroy_at(addressof(val));
|
| 165 |
+
} else {
|
| 166 |
+
destroy_at(addressof(unex));
|
| 167 |
+
has_val = true;
|
| 168 |
+
}
|
| 169 |
+
return *construct_at(addressof(val), std::forward<Args>(args)...);
|
| 170 |
+
```
|
| 171 |
+
|
| 172 |
+
``` cpp
|
| 173 |
+
template<class U, class... Args>
|
| 174 |
+
constexpr T& emplace(initializer_list<U> il, Args&&... args) noexcept;
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
*Constraints:*
|
| 178 |
+
`is_nothrow_constructible_v<T, initializer_list<U>&, Args...>` is
|
| 179 |
+
`true`.
|
| 180 |
+
|
| 181 |
+
*Effects:* Equivalent to:
|
| 182 |
+
|
| 183 |
+
``` cpp
|
| 184 |
+
if (has_value()) {
|
| 185 |
+
destroy_at(addressof(val));
|
| 186 |
+
} else {
|
| 187 |
+
destroy_at(addressof(unex));
|
| 188 |
+
has_val = true;
|
| 189 |
+
}
|
| 190 |
+
return *construct_at(addressof(val), il, std::forward<Args>(args)...);
|
| 191 |
+
```
|
| 192 |
+
|