4.1 KiB
[expected.void.assign]
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().
Returns: *this.
Remarks: This operator is defined as deleted unlessis_copy_assignable_v is true andis_copy_constructible_v is true.
constexpr expected& operator=(expected&& rhs) noexcept(see below);
Constraints: is_move_constructible_v is true andis_move_assignable_v 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()).
Returns: *this.
Remarks: The exception specification is equivalent tois_nothrow_move_constructible_v && is_nothrow_move_assignable_v.
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(e.error()));has_val = false;
Otherwise, equivalent to:unex = std::forward(e.error());
Returns: *this.
constexpr void emplace() noexcept;
Effects: If has_value() is false, destroys unex and sets has_val to true.