[expected.void.assign] (original) (raw)
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.4 Assignment [expected.void.assign]
constexpr expected& operator=(const expected& rhs);
Effects:
- If this->has_value() && rhs.has_value() is true, no effects.
- Otherwise, if this->has_value() is true, equivalent to: construct_at(addressof(unex), rhs.unex); has_val = false;
- Otherwise, if rhs.has_value() is true, destroys unex and sets has_val to true.
- Otherwise, equivalent to unex = rhs.error().
Remarks: This operator is defined as deleted unlessis_copy_assignable_v<E> is true andis_copy_constructible_v<E> is true.
constexpr expected& operator=(expected&& rhs) noexcept(_see below_);
Constraints: is_move_constructible_v<E> is true andis_move_assignable_v<E> is true.
Effects:
- If this->has_value() && rhs.has_value() is true, no effects.
- Otherwise, if this->has_value() is true, equivalent to:construct_at(addressof(unex), std::move(rhs.unex));has_val = false;
- Otherwise, if rhs.has_value() is true, destroys unex and sets has_val to true.
- Otherwise, equivalent to unex = std::move(rhs.error()).
Remarks: The exception specification is equivalent tois_nothrow_move_constructible_v<E> && is_nothrow_move_assignable_v<E>.
template<class G> constexpr expected& operator=(const unexpected<G>& e);template<class G> constexpr expected& operator=(unexpected<G>&& e);
Let GF be const G& for the first overload andG for the second overload.
Constraints: is_constructible_v<E, GF> is true andis_assignable_v<E&, GF> is true.
Effects:
- If has_value() is true, equivalent to:construct_at(addressof(unex), std::forward<GF>(e.error()));has_val = false;
- Otherwise, equivalent to:unex = std::forward<GF>(e.error());
constexpr void emplace() noexcept;
Effects: If has_value() is false, destroys unex and sets has_val to true.