ev-json-spaceship-value-type-002¶
| 字段 | 值 |
|---|---|
| 项目 | nlohmann/json |
| 固定 commit | 55f93686c015 |
| 路径 | include/nlohmann/detail/value_t.hpp |
| 行段 | L95-L100 |
| 特性 | 三路比较运算符 <=> |
| 许可证 | MIT |
| 代码来源 | 项目源码 |
| 级别 | manual |
| 审核 | zyuhao7 @ 2026-10-24 |
| 测试代码 | 否 |
| 发现方式 | regex |
用法¶
按预定义顺序比较值类型,无法比较时返回 unordered
为什么典型¶
JSON 类型序不构成全序,返回 partial_ordering 并显式给出 unordered,是偏序的典型用法。
摘录¶
#if JSON_HAS_THREE_WAY_COMPARISON
if (l_index < order.size() && r_index < order.size())
{
return order[l_index] <=> order[r_index]; // *NOPAD*
}
return std::partial_ordering::unordered;
备注¶
生产路径;保留条件分支与无序返回值。