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:: strong_ordering ( std:: compare_three_way ( ) ( t, u ) ) (如果该表达式良构)。
-
std::
strong_ordering
(
strong_order
(
t, u
)
)
,前提是这是一个良构的表达式,且重载决议在不包含
- 所有其他情况下,该表达式为非良构,在模板实例化的直接上下文中可能出现 替换失败 。
目录 |
定制点对象
名称
std::strong_order
表示一个
定制点对象
,它是一个字面量
semiregular
类类型的常量
函数对象
。详细信息请参阅
定制点对象
。
IEEE浮点类型的严格全序
设 x 和 y 为相同 IEEE 浮点类型的值,且 total_order_less ( x, y ) 为布尔结果,指示 x 是否在 ISO/IEC/IEEE 60559 中 totalOrder 定义的严格全序中先于 y 。
( total_order_less ( x, y ) || total_order_less ( y, x ) ) == false 当且仅当 x 与 y 具有相同的位模式。
-
若
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
类型的结果
(定制点对象) |
|
(C++20)
|
执行三路比较并生成
std::strong_ordering
类型的结果,即使
operator
<=>
不可用
(定制点对象) |