std::strong_order
|   在标头  <compare> 定义
  | 
||
|   inline namespace /* 未指定 */ {     inline constexpr /* 未指定 */ strong_order = /* 未指定 */;  | 
(C++20 起) | |
|   调用签名  | 
||
|   template< class T, class U >     requires /* 见下文 */  | 
||
用三路比较比较两个值,并产生 std::strong_ordering 类型结果。
设 t 与 u 为表达式, T 与 U 分别指代 decltype((t)) 与 decltype((u)),那么 std::strong_order(t, u) 表达式等价于:
-  如果 std::is_same_v<std::decay_t<T>, std::decay_t<U>> 是 true:
-  std::strong_ordering(strong_order(t, u)),如果在不包含 
std::strong_order的声明的语境中进行重载决议的情况下该表达式良构, -  否则,如果 
T是浮点类型:-  如果 std::numeric_limits<T>::is_iec559 是 true,那么进行浮点值的 ISO/IEC/IEEE 60559 totalOrder 比较并返回 
std::strong_ordering类型值作为结果(注意:此比较能区别正与负零及有不同表示的 NaN), -  否则,产生与 
T的比较运算符所观察的顺序一致的std::strong_ordering类型值, 
 -  如果 std::numeric_limits<T>::is_iec559 是 true,那么进行浮点值的 ISO/IEC/IEEE 60559 totalOrder 比较并返回 
 - 否则是 std::strong_ordering(std::compare_three_way()(t, u)),如果它良构。
 
 -  std::strong_ordering(strong_order(t, u)),如果在不包含 
 - 所有其他情况下,表达式非良构,在出现于模板实例化的立即语境时这会导致替换失败。
 
定制点对象
名字 std::strong_order 代表一个定制点对象,它是字面 semiregular 类类型的 const 函数对象。为说明目的,以 __strong_order_fn 表示它的类型的 cv 无限定版本。
__strong_order_fn 的所有实例均相等。在相同参数上调用类型 __strong_order_fn 的不同实例的效果是等价的,与指代该实例的表达式是左值还是右值,以及是否为 const 限定无关(然而不要求 volatile 限定的实例可调用)。从而能自由地复制 std::strong_order 并且能彼此替代地使用它的副本。
给定类型集合 Args...,如果 std::declval<Args>()... 满足上面对于 std::strong_order 的参数要求,那么 __strong_order_fn 实现
- std::invocable<__strong_order_fn, Args...>、
 - std::invocable<const __strong_order_fn, Args...>、
 - std::invocable<__strong_order_fn&, Args...> 和
 - std::invocable<const __strong_order_fn&, Args...>。
 
否则,__strong_order_fn 的函数调用运算符不会参与重载决议。
IEEE 浮点类型的严格全序
令 x 和 y 为相同 IEEE 浮点类型的值,而 total_order_less(x, y) 为指示在 ISO/IEC/IEEE 60559 中的 totalOrder 所定义的严格全序中 x 是否前趋于 y 的布尔结果。
当且仅当 x 和 y 拥有同一位模式时,total_order_less(x, y) || total_order_less(y, x) == false。
-  如果 x 和 y 都不是 NaN:
- 如果 x < y,那么 total_order_less(x, y) == true;
 - 如果 x > y,那么 total_order_less(x, y) == false;
 -  如果 x == y,
- 如果 x 是负零且 y 是正零,那么 total_order_less(x, y) == true;
 - 如果 x 非零且 x 的指数域小于 y 的,那么 total_order_less(x, y) == (x > 0)(仅对十进制浮点数有意义);
 
 
 -  如果 x 或 y 是 NaN:
- 如果 x 是负 NaN 且 y 不是负 NaN,那么 total_order_less(x, y) == true;
 - 如果 x 不是正 NaN 且 y 是正 NaN,那么 total_order_less(x, y) == true;
 - 如果 x 和 y 都是拥有相同符号的 NaN 且 x 的尾数域小于 y 的,那么 total_order_less(x, y) == !std::signbit(x)。
 
 
示例
| 本节未完成 原因:暂无示例  | 
参阅
|    (C++20)  | 
  三路比较的结果类型,支持所有 6 种运算符且可替换  (类)  | 
|    (C++20)  | 
  进行三路比较并产生 std::weak_ordering 类型结果 (定制点对象)  | 
|    (C++20)  | 
  进行三路比较并产生 std::partial_ordering 类型结果 (定制点对象)  | 
  进行三路比较并产生 std::strong_ordering 类型的结果,即使 operator<=> 不可用 (定制点对象)  |