c++ - 为什么 std::strong_ordering 有一个“等效”值?
问题描述
的有效值为std::strong_ordering
、less
、equal
和。然而,看起来和是相等的(即,可互换的),因为在这两种情况下,仅展示字段都等于零,并且没有其他状态可供仅展示构造函数初始化。equivalent
greater
strong_ordering::equivalent
strong_ordering::equal
value
strong_ordering
没有任何单独 的值是有道理的equivalent
,因为当排序很强时,等价的值总是相等的。但是,为 做strong_ordering::equivalent
一个同义词strong_ordering::equal
而不是根本不定义它有什么意义呢?
解决方案
This allows C::equivalent
to be defined for all comparison categories C
. There used to be five of them, all of which had this, now just the three.
If you need something like that, it helps to have it. And it costs nothing to provide, so... there it is.
推荐阅读
- javascript - 分页 Vue.js 表格并使搜索栏跨表格页面工作
- css - 根据数据主题更改 ::selection
- php - 将 SOAP XML 解析为数组
- python - 不和谐的表情符号在代码中表现得很奇怪,3 个 ascii 符号的数字包
- javascript - React:如何将“未定义”变量作为道具传递给组件?
- python - 在启动时从 powershell 脚本作为 Windows 服务运行 python 代码
- node.js - 未捕获的 SyntaxError:JSON.parse 处的 JSON 输入意外结束?
- python - 我怎样才能只检索那些包含 3 个连续数字的列?
- amazon-web-services - AWS EC2-Instance 备份/终止/启动的最佳实践是什么
- makefile - makefile 规则中先决条件和目标之间的最小时间差