operator==(std::expected)
来自cppreference.com
                    
                                        
                    
                    
                                                            
                    |   template< class T2, class E2 >   requires (!std::is_void_v<T2>)  | 
(1) |  (C++23 起)  (T 不是 cv void)  | 
|   template< class T2, class E2 >   requires std::is_void_v<T2>  | 
(2) |  (C++23 起)  (T 是 cv void)  | 
|   template< class T2 > friend constexpr bool operator==( const expected& x, const T2& val );  | 
(3) |  (C++23 起)  (T 不是 cv void)  | 
|   template< class E2 > friend constexpr bool operator==( const expected& x,  | 
(4) | (C++23 起) | 
对 expected 对象执行比较操作。
1,2) 比较两个 
expected 对象。当且仅当 lhs.has_value() 和 rhs.has_value() 相等,且所含值相等时,对象才比较相等。
- 对于重载 (1),如果表达式 *lhs == *rhs 和 lhs.error() == rhs.error() 不具有良好定义,或者它们的结果不能转换为 bool,则程序非良构。
 - 对于重载 (2),如果表达式 lhs.error() == rhs.error() 不具有良好定义,或者它的结果不能转换 为bool,则程序非良构。
 
3) 将 
expected 对象与一个值比较。当且仅当 x 包含一个期望值,且所含值等于 val 时,对象才比较相等。
- 如果表达式*x == val 不具有良好定义,或者它的结果不能转换为 bool,则程序非良构。
 
4) 将 
expected 对象与一个非期望值比较。当且仅当 x 包含一个非期望值,且所含值等于 e.error() 时,对象才比较相等。
- 如果表达式 x.error() == e.error() 不具有良好定义,或者它的结果不能转换为 bool,则程序非良构。
 
这些函数对通常无限定或有限定查找不可见,而只能在 std::expected<T, E> 为参数的关联类时由实参依赖查找找到。
!= 运算符从 == 运算符合成。
参数
| lhs, rhs, x | - |   用于比较的 expected 对象
 | 
| val | - |   需要被比较的包含在 x 中的期望的值
 | 
| e | - |   需要被比较的包含在 x 中的非期望的值
 | 
返回值
1) 如果 lhs.has_value() != rhs.has_value() 为真,返回 false。此外,如果 lhs.has_value() 为真,返回 *lhs == *rhs。否则,返回 lhs.error() ==  rhs.error()。
2) 如果 lhs.has_value() != rhs.has_value() 为真,返回 false。此外,如果  lhs.has_value() 为真,返回 true。否则,返回 lhs.error() ==  rhs.error()。
3) 返回 x.has_value() && static_cast<bool>(*x == val).
4) 返回 !x.has_value() && static_cast<bool>(x.error() == e.error()).
异常
抛出比较时抛出的异常。
示例
| 本节未完成 原因:暂无示例  | 
参阅
|    (C++23)  | 
   表示为不期待的值   (类模板)  |