2.2 KiB
2.2 KiB
[expected.void.swap]
22 General utilities library [utilities]
22.8 Expected objects [expected]
22.8.7 Partial specialization of expected for void types [expected.void]
22.8.7.5 Swap [expected.void.swap]
constexpr void swap(expected& rhs) noexcept(see below);
Constraints: is_swappable_v is true andis_move_constructible_v is true.
Table 73 — swap(expected&) effects [tab:expected.void.swap]
| ð | this->has_value() | !this->has_value() |
|---|---|---|
| ð rhs.has_value() |
no effects | calls rhs.swap(*this) |
| ð !rhs.has_value() |
see below | equivalent to: using std::swap; swap(unex, rhs.unex); |
For the case where rhs.has_value() is false andthis->has_value() is true, equivalent to:construct_at(addressof(unex), std::move(rhs.unex)); destroy_at(addressof(rhs.unex));has_val = false; rhs.has_val = true;
Throws: Any exception thrown by the expressions in the Effects.
Remarks: The exception specification is equivalent tois_nothrow_move_constructible_v && is_nothrow_swappable_v.
friend constexpr void swap(expected& x, expected& y) noexcept(noexcept(x.swap(y)));
Effects: Equivalent to x.swap(y).