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

74 lines
2.4 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.object.eq]
# 22 General utilities library [[utilities]](./#utilities)
## 22.8 Expected objects [[expected]](expected#object.eq)
### 22.8.6 Class template expected [[expected.expected]](expected.expected#expected.object.eq)
#### 22.8.6.8 Equality operators [expected.object.eq]
[🔗](#lib:operator==,expected)
`template<class T2, class E2> requires (!is_void_v<T2>)
friend constexpr bool operator==(const expected& x, const expected<T2, E2>& y);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9368)
*Constraints*: The expressions *x == *y and x.error() == y.error() are well-formed and their results are convertible to bool[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9373)
*Returns*: If x.has_value() does not equal y.has_value(), false;
otherwise if x.has_value() is true, *x == *y;
otherwise x.error() == y.error()[.](#2.sentence-1)
[🔗](#lib:operator==,expected_)
`template<class T2> friend constexpr bool operator==(const expected& x, const T2& v);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9386)
*Constraints*: T2 is not a specialization of expected[.](#3.sentence-1)
The expression *x == v is well-formed and
its result is convertible to bool[.](#3.sentence-2)
[*Note [1](#note-1)*:
T need not be [*Cpp17EqualityComparable*](utility.arg.requirements#:Cpp17EqualityComparable "16.4.4.2Template argument requirements[utility.arg.requirements]")[.](#3.sentence-3)
— *end note*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9395)
*Returns*: x.has_value() && static_cast<bool>(*x == v)[.](#4.sentence-1)
[🔗](#lib:operator==,expected__)
`template<class E2> friend constexpr bool operator==(const expected& x, const unexpected<E2>& e);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9406)
*Constraints*: The expression x.error() == e.error() is well-formed and
its result is convertible to bool[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9411)
*Returns*: !x.has_value() && static_cast<bool>(x.error() == e.error())[.](#6.sentence-1)