std::weak_order
来自cppreference.com
                    
                                        
                    
                    
                                                            
                    |   定义于头文件  <compare>
  | 
||
|   inline namespace /* unspecified */ {     inline constexpr /* unspecified */ weak_order = /* unspecified */;  | 
(C++20 起) | |
|   调用签名  | 
||
|   template< class T, class U >     requires /* see below */  | 
||
用三路比较比较二个值并产生 std::weak_ordering 类型结果。
设 t 与 u 为表达式而 T 与 U 分别代表 decltype((t)) 与 decltype((u)) 类型的值,则 std::weak_order(t, u) 表达式等价于:
-  若 std::is_same_v<std::decay_t<T>, std::decay_t<U>> == true :
-  std::weak_ordering(weak_order(t, u)) ,若在不包含 
std::weak_order的声明的语境中进行重载决议的情况下它为良构的表达式, -  否则,若 
T为浮点类型:- 若 std::numeric_limits<T>::is_iec559 为 true ,则进行浮点值的弱序比较(见后述)并返回 std::weak_ordering 类型值作为结果,
 -  否则,产生与 
T的比较运算符所观察的顺序一致的 std::weak_ordering 类型值, 
 - 否则为 std::weak_ordering(std::compare_three_way()(t, u)) ,若它为良构,
 - 否则为 std::weak_ordering(std::strong_order(t, u)) ,若它为良构,
 - 否则该表达式为非良构,这能在出现于模板实例化的立即语境时导致替换失败。
 
 -  std::weak_ordering(weak_order(t, u)) ,若在不包含 
 - 否则, std::weak_order(t, u) 为非良构。
 
表达式等价
表达式 e 表达式等价于表达式 f ,若 e 与 f 拥有相同效果,均为潜在抛出或均非潜在抛出(即 noexcept(e) == noexcept(f) ),且均为常量子表达式或均非常量子表达式。
定制点对象
名字 std::weak_order 代表一个定制点对象,它是字面 semiregular 类类型(为说明目的以 weak_order_ftor 表示)的 const 函数对象。weak_order_ftor 的所有实例均相等。从而能自由地复制 std::weak_order ,且能交替使用其副本。
给定类型集合 Args... ,若 std::declval<Args>()... 满足上面对于 std::weak_order 的参数要求,则 weak_order_ftor 将满足 std::invocable<const weak_order_ftor&, Args...> 。否则, weak_order_ftor 的函数调用运算符不参与重载决议。
注解
IEEE 浮点类型的严格弱序
设 x 与 y 表示相同 IEEE 浮点类型的值,而 weak_order_less(x, y) 为指示在 C++标准定义的严格弱序中 x 是否前趋于 y 的布尔结果。
-  若 
x与y均非 NaN ,则 weak_order_less(x, y) == true 当且仅当 x < y ,即相等浮点值的所有表示等价; -  若 
x为负 NaN 且y不是负 NaN ,则 weak_order_less(x, y) == true ; -  若 
x不是正 NaN 且y为正 NaN ,则 weak_order_less(x, y) == true ; -  若 
x与y均为拥有同一符号的 NaN ,则 weak_order_less(x, y) || weak_order_less(y, x) == false ,即所有符号相同的 NaN 等价。 
示例
| 本节未完成 原因:暂无示例  | 
参阅
|    (C++20)  | 
  三路比较的结果类型,支持所有 6 种运算符且不可替换  (类)  | 
|    (C++20)  | 
  进行三路比较并产生 std::strong_ordering 类型结果 (定制点对象)  | 
|    (C++20)  | 
  进行三路比较并产生 std::partial_ordering 类型结果 (定制点对象)  | 
|    (C++20)  | 
   进行三路比较并产生 std::weak_ordering 类型的结果,即使 operator<=> 不可用 (定制点对象)  |