[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 requires (!is_void_v) friend constexpr bool operator==(const expected& x, const expected& 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 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.2 Template 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(*x == v)[.](#4.sentence-1) [🔗](#lib:operator==,expected__) `template friend constexpr bool operator==(const expected& x, const unexpected& 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(x.error() == e.error())[.](#6.sentence-1)