std::weak_ordering
来自cppreference.com
                    
                                        
                    
                    
                                                            
                    |   在标头  <compare> 定义
  | 
||
|   class weak_ordering;  | 
(C++20 起) | |
类类型 std::weak_ordering 是这种三路比较的结果类型:
- 接纳所有六个关系运算符( == 、 != 、 < 、 <= 、 > 、 >= )
 
- 不隐含可替换性:若 a 等价于 b ,则 f(a) 可能不等价于 f(b) 。这里 f 所指代的函数仅可经由参数的公开 const 成员读取显著的比较状态。换言之,等价的值可能可区别。
 - 不允许不可比较值: a < b 、 a == b 和 a > b 必须恰有一个为 true
 
常量
类型 std::weak_ordering 有三个合法值,实现为其类型的 const 静态数据成员:
| 成员常量 | 定义 | 
|    less(inline constexpr) [静态]  | 
  std::weak_ordering 类型合法值,指示小于(先序)关系 (公开静态成员常量)  | 
|    equivalent(inline constexpr) [静态]  | 
  std::weak_ordering 类型合法值,指示等价(既非先序亦非后序) (公开静态成员常量)  | 
|    greater(inline constexpr) [静态]  | 
  std::weak_ordering 类型合法值,指示大于(后序)关系 (公开静态成员常量)  | 
转换
std::weak_ordering 可隐式转换为 std::partial_ordering ,而 std::strong_ordering 可隐式转换为 weak_ordering 。
|     operator partial_ordering  | 
  到 std::partial_ordering 的隐式转换  (公开成员函数)  | 
std::weak_ordering::operator partial_ordering
|   constexpr operator partial_ordering() const noexcept;  | 
||
返回值
若 v 为 less 则为 std::partial_ordering::less ,若 v 为 greater 则为 std::partial_ordering::greater ,若 v 为 equivalent 则为
std::partial_ordering::equivalent 。
比较
比较运算符在此类型值和字面量 0 间定义。这支持用表达式 a <=> b == 0 或 a <=> b < 0 转换三路比较的结果为布尔关系;见 std::is_eq 、 std::is_lt 等。
这些函数对通常无限定或有限定查找不可见,而只能在 std::weak_ordering 为参数的关联类时由实参依赖查找找到。
若程序试图将 weak_ordering 与任何异于整数字面量 0 的内容比较,则其行为未定义。
|     operator==operator<operator>operator<=operator>=operator<=>  | 
  与零或 weak_ordering 比较 (函数)  | 
operator==
|   friend constexpr bool operator==(weak_ordering v, /*unspecified*/ u) noexcept;  | 
(1) | |
|   friend constexpr bool operator==(weak_ordering v, weak_ordering w) noexcept = default;  | 
(2) | |
参数
| v, w | - |  要检查的 std::weak_ordering 值
 | 
| u | - | 任何接受字面零实参的类型的不使用形参 | 
返回值
1) 若 
v 为 equivalent 则为 true ,若 v 为 less 或 greater 则为 false 。2) 若两个参数持有相同值则为 true ,否则为 false 。
operator<
|   friend constexpr bool operator<(weak_ordering v, /*unspecified*/ u) noexcept;  | 
(1) | |
|   friend constexpr bool operator<(/*unspecified*/ u, weak_ordering v) noexcept;  | 
(2) | |
参数
| v | - |  要检查的 std::weak_ordering 值
 | 
| u | - | 任何接受字面零实参的类型的不使用形参 | 
返回值
1) 若 
v 为 less 则为 true ,而若 v 为 greater 或 equivalent 则为 false 。2) 若 
v 为 greater 则为 true ,而若 v 为 less 或 equivalent 则为 false 。
operator<=
|   friend constexpr bool operator<=(weak_ordering v, /*unspecified*/ u) noexcept;  | 
(1) | |
|   friend constexpr bool operator<=(/*unspecified*/ u, weak_ordering v) noexcept;  | 
(2) | |
参数
| v | - |  要检查的 std::weak_ordering 值
 | 
| u | - | 任何接受字面零实参的类型的不使用形参 | 
返回值
1) 若 
v 为 less 或 equivalent 则为 true ,而若 v 为 greater 则为 false 。2) 若 
v 为 greater 或 equivalent 则为 true ,而若 v 为 less 则为 false 。
operator>
|   friend constexpr bool operator>(weak_ordering v, /*unspecified*/ u) noexcept;  | 
(1) | |
|   friend constexpr bool operator>(/*unspecified*/ u, weak_ordering v) noexcept;  | 
(2) | |
参数
| v | - |  要检查的 std::weak_ordering 值
 | 
| u | - | 任何接受字面零实参的类型的不使用形参 | 
返回值
1) 若 
v 为 greater 则为 true ,而若 v 为 less 或 equivalent 则为 false 。2) 若 
v 为 less 则为 true ,而若 v 为 greater 或 equivalent 则为 false 。
operator>=
|   friend constexpr bool operator>=(weak_ordering v, /*unspecified*/ u) noexcept;  | 
(1) | |
|   friend constexpr bool operator>=(/*unspecified*/ u, weak_ordering v) noexcept;  | 
(2) | |
参数
| v | - |  要检查的 std::weak_ordering 值
 | 
| u | - | 任何接受字面零实参的类型的不使用形参 | 
返回值
1) 若 
v 为 greater 或 equivalent 则为 true ,而若 v 为 less 则为 false 。1) 若 
v 为 less 或 equivalent 则为 true ,而若 v 为 greater 则为 false 。
operator<=>
|   friend constexpr weak_ordering operator<=>(weak_ordering v, /*unspecified*/ u) noexcept;  | 
(1) | |
|   friend constexpr weak_ordering operator<=>(/*unspecified*/ u, weak_ordering v) noexcept;  | 
(2) | |
参数
| v | - |  要检查的 std::weak_ordering 值
 | 
| u | - | 任何接受字面零实参的类型的不使用形参 | 
返回值
1) v 。
2) 若 
v 为 less 则为 greater ,若 v 为 greater 则为 less ,否则为 v 。
示例
| 本节未完成 原因:暂无示例  | 
参阅
|    (C++20)  | 
  三路比较的结果类型,支持所有 6 种运算符且可替换  (类)  | 
|    (C++20)  | 
  三路比较的结果类型,支持所有 6 种运算符,不可替换,并允许不可比较的值  (类)  |