Files
2025-10-25 03:02:53 +03:00

149 lines
4.1 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[expected.void.assign]
# 22 General utilities library [[utilities]](./#utilities)
## 22.8 Expected objects [[expected]](expected#void.assign)
### 22.8.7 Partial specialization of expected for void types [[expected.void]](expected.void#assign)
#### 22.8.7.4 Assignment [expected.void.assign]
[🔗](#lib:operator=,expected%3cvoid%3e)
`constexpr expected& operator=(const expected& rhs);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9771)
*Effects*:
- [(1.1)](#1.1)
If this->has_value() && rhs.has_value() is true, no effects[.](#1.1.sentence-1)
- [(1.2)](#1.2)
Otherwise, if this->has_value() is true,
equivalent to: construct_at(addressof(*unex*), rhs.*unex*); *has_val* = false;
- [(1.3)](#1.3)
Otherwise, if rhs.has_value() is true,
destroys *unex* and sets *has_val* to true[.](#1.3.sentence-1)
- [(1.4)](#1.4)
Otherwise, equivalent to *unex* = rhs.error()[.](#1.4.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9786)
*Returns*: *this[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9790)
*Remarks*: This operator is defined as deleted unlessis_copy_assignable_v<E> is true andis_copy_constructible_v<E> is true[.](#3.sentence-1)
[🔗](#lib:operator=,expected%3cvoid%3e_)
`constexpr expected& operator=(expected&& rhs) noexcept(see below);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9803)
*Constraints*: is_move_constructible_v<E> is true andis_move_assignable_v<E> is true[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9808)
*Effects*:
- [(5.1)](#5.1)
If this->has_value() && rhs.has_value() is true, no effects[.](#5.1.sentence-1)
- [(5.2)](#5.2)
Otherwise, if this->has_value() is true, equivalent to:construct_at(addressof(*unex*), std::move(rhs.*unex*));*has_val* = false;
- [(5.3)](#5.3)
Otherwise, if rhs.has_value() is true,
destroys *unex* and sets *has_val* to true[.](#5.3.sentence-1)
- [(5.4)](#5.4)
Otherwise, equivalent to *unex* = std::move(rhs.error())[.](#5.4.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9826)
*Returns*: *this[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9830)
*Remarks*: The exception specification is equivalent tois_nothrow_move_constructible_v<E> && is_nothrow_move_assignable_v<E>[.](#7.sentence-1)
[🔗](#lib:operator=,expected%3cvoid%3e__)
`template<class G>
constexpr expected& operator=(const unexpected<G>& e);
template<class G>
constexpr expected& operator=(unexpected<G>&& e);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9845)
Let GF be const G& for the first overload andG for the second overload[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9849)
*Constraints*: is_constructible_v<E, GF> is true andis_assignable_v<E&, GF> is true[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9854)
*Effects*:
- [(10.1)](#10.1)
If has_value() is true, equivalent to:construct_at(addressof(*unex*), std::forward<GF>(e.error()));*has_val* = false;
- [(10.2)](#10.2)
Otherwise, equivalent to:*unex* = std::forward<GF>(e.error());
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9868)
*Returns*: *this[.](#11.sentence-1)
[🔗](#lib:emplace,expected%3cvoid%3e)
`constexpr void emplace() noexcept;
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9879)
*Effects*: If has_value() is false,
destroys *unex* and sets *has_val* to true[.](#12.sentence-1)