Qt::partial_ordering Class
class Qt::partial_orderingQt::partial_ordering 表示允许无序比较的结果。更多
头文件: | #include <QtCompare> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
自 | Qt 6.7 |
公共函数
partial_ordering(std::partial_ordering stdorder) | |
std::partial_ordering | operator std::partial_ordering() const |
静态公共成员
const Qt::partial_ordering | equivalent |
const Qt::partial_ordering | greater |
const Qt::partial_ordering | less |
const Qt::partial_ordering | unordered |
相关非成员
bool | is_eq(Qt::partial_ordering o) |
bool | is_gt(Qt::partial_ordering o) |
bool | is_gteq(Qt::partial_ordering o) |
bool | is_lt(Qt::partial_ordering o) |
bool | is_lteq(Qt::partial_ordering o) |
bool | is_neq(Qt::partial_ordering o) |
bool | operator!=(Qt::partial_ordering lhs, Qt::partial_ordering rhs) |
bool | operator==(Qt::partial_ordering lhs, Qt::partial_ordering rhs) |
详细说明
三向比较函数通常会返回Qt::partial_ordering 类型的值。此类函数比较两个对象,确定它们是否有序,如果有序,则确定它们的排序。它使用这种返回类型来表示排序是部分的;也就是说,并非所有值对都是有序的。
Qt::partial_ordering 有四个值,用以下符号常量表示:
- less 表示左操作数小于右操作数;
- equivalent 表示两个操作数相等;
- greater 表示左操作数大于右操作数;
- unordered 表示两个操作数没有排序。
Qt::partial_ordering 在比较一个实例和一个字面 0 时,"...... "被惯常使用,例如像这样:
// given a, b, c, d as objects of some type that allows for a 3-way compare, // and a compare function declared as follows: Qt::partial_ordering compare(T lhs, T rhs); // defined out-of-line ~~~ Qt::partial_ordering result = compare(a, b); if (result < 0) { // a is less than b } if (compare(c, d) >= 0) { // c is greater than or equal to d }
将Qt::partial_ordering::unordered 与字面 0 比较,总是返回false
结果。
另请参阅 Qt::strong_ordering,Qt::weak_ordering, 以及比较类型概述。
成员函数文档
[constexpr noexcept]
partial_ordering::partial_ordering(std::partial_ordering stdorder)
使用以下规则从stdorder 构造Qt::partial_ordering 对象:
- std::partial_ordering::less 转换为less 。
- std::partial_ordering::equivalent 转换为equivalent 。
- std::partial_ordering::greater 转换到greater 。
- std::partial_ordering::unordered 会转换为unordered
[constexpr noexcept]
std::partial_ordering partial_ordering::operator std::partial_ordering() const
使用以下规则将Qt::partial_ordering 值转换为 std::partial_ordering 对象:
- less 转换为 std::partial_ordering::less。
- equivalent 转换为 std::partial_ordering::equivalent。
- greater 转换为 std::partial_ordering::g greater。
- unordered 转换为 std::partial_ordering::unordered。
成员变量文档
const Qt::partial_ordering partial_ordering::equivalent
表示两个操作数等价的比较结果。
const Qt::partial_ordering partial_ordering::greater
表示左操作数大于右操作数的比较结果。
const Qt::partial_ordering partial_ordering::less
表示左操作数小于右操作数的比较结果。
const Qt::partial_ordering partial_ordering::unordered
表示两个操作数之间没有排序关系的比较结果。
相关非成员
[constexpr noexcept]
bool is_eq(Qt::partial_ordering o)
[constexpr noexcept]
bool is_gt(Qt::partial_ordering o)
[constexpr noexcept]
bool is_gteq(Qt::partial_ordering o)
[constexpr noexcept]
bool is_lt(Qt::partial_ordering o)
[constexpr noexcept]
bool is_lteq(Qt::partial_ordering o)
[constexpr noexcept]
bool is_neq(Qt::partial_ordering o)
将o 转换为六个关系运算符之一的结果:
函数 | 操作 |
---|---|
is_eq | o == 0 |
is_neq | o != 0 |
is_lt | o < 0 |
is_lteq | o <= 0 |
is_gt | o > 0 |
is_gteq | o >= 0 |
提供这些函数是为了与std::partial_ordering
兼容。
[constexpr noexcept]
bool operator!=(Qt::partial_ordering lhs, Qt::partial_ordering rhs)
如果lhs 和rhs 表示不同的结果,则返回 true;否则返回 true。
[constexpr noexcept]
bool operator==(Qt::partial_ordering lhs, Qt::partial_ordering rhs)
如果lhs 和rhs 表示相同的结果,则返回 true;否则,返回 false。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.