22 General utilities library [utilities]

22.8 Expected objects [expected]

22.8.7 Partial specialization of expected for void types [expected.void] 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]
no effects
calls rhs.swap(*this)
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).