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<E> is true and is_­move_­constructible_­v<E> is true.
Effects: See Table 65.
Table 65: 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.value() is false and this->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 to is_­nothrow_­move_­constructible_­v<E> && is_­nothrow_­swappable_­v<E>.
friend constexpr void swap(expected& x, expected& y) noexcept(noexcept(x.swap(y)));
Effects: Equivalent to x.swap(y).