Qt::strong_ordering Class
class Qt::strong_orderingQt::strong_ordering 表示等值无差别的比较。更多
头文件: | #include <QtCompare> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
自 | Qt 6.7 |
公共函数
strong_ordering(std::strong_ordering stdorder) | |
Qt::partial_ordering | operator Qt::partial_ordering() const |
Qt::weak_ordering | operator Qt::weak_ordering() const |
std::strong_ordering | operator std::strong_ordering() const |
静态公共成员
const Qt::strong_ordering | equal |
const Qt::strong_ordering | equivalent |
const Qt::strong_ordering | greater |
const Qt::strong_ordering | less |
相关非成员
bool | is_eq(Qt::strong_ordering o) |
bool | is_gt(Qt::strong_ordering o) |
bool | is_gteq(Qt::strong_ordering o) |
bool | is_lt(Qt::strong_ordering o) |
bool | is_lteq(Qt::strong_ordering o) |
bool | is_neq(Qt::strong_ordering o) |
bool | operator!=(Qt::strong_ordering lhs, Qt::strong_ordering rhs) |
bool | operator==(Qt::strong_ordering lhs, Qt::strong_ordering rhs) |
详细说明
三向比较函数通常会返回Qt::strong_ordering 类型的值。此类函数比较两个对象,并确定它们的排序方式。它使用这种返回类型来表示排序是严格的;也就是说,函数建立了一个定义明确的总顺序。
Qt::strong_ordering 有四个值,用以下符号常量表示:
- less 表示左操作数小于右操作数;
- equal 表示左操作数等同于右操作数;
- equivalent 是 的别名;
equal
- greater 表示左操作数大于右操作数。
Qt::strong_ordering 的别名;表示左操作数大于右操作数:
// 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::strong_ordering compare(T lhs, T rhs); // defined out-of-line ~~~ Qt::strong_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::weak_ordering,Qt::partial_ordering, 以及比较类型概述。
成员函数文档
[constexpr noexcept]
strong_ordering::strong_ordering(std::strong_ordering stdorder)
使用以下规则从stdorder 构造Qt::strong_ordering 对象:
- std::strong_ordering::less 转换为less 。
- std::strong_ordering::equivalent 转换为equivalent 。
- std::strong_ordering::equal 转换到equal 。
- std::strong_ordering::greater 转换到greater 。
[constexpr noexcept]
Qt::partial_ordering strong_ordering::operator Qt::partial_ordering() const
使用以下规则将Qt::strong_ordering 值转换为Qt::partial_ordering 对象:
- less 转换为 .Qt::partial_ordering::less
- equivalent 转换为 .Qt::partial_ordering::equivalent
- equal 转换为 .Qt::partial_ordering::equivalent
- greater 转换为 .Qt::partial_ordering::greater
[constexpr noexcept]
Qt::weak_ordering strong_ordering::operator Qt::weak_ordering() const
使用以下规则将Qt::strong_ordering 值转换为Qt::weak_ordering 对象:
- less 转换为 .Qt::weak_ordering::less
- equivalent 转换为 .Qt::weak_ordering::equivalent
- equal 转换为 .Qt::weak_ordering::equivalent
- greater 转换为 .Qt::weak_ordering::greater
[constexpr noexcept]
std::strong_ordering strong_ordering::operator std::strong_ordering() const
使用以下规则将Qt::strong_ordering 值转换为 std::strong_ordering 对象:
- less 转换为 std::strong_ordering::less。
- equivalent 转换为 std::strong_ordering::equivalent。
- equal 转换为 std::strong_ordering::equivalent。
- greater 转换为 std::strong_ordering::g greater。
成员变量文档
const Qt::strong_ordering strong_ordering::equal
表示左操作数等于右操作数的比较结果。与Qt::strong_ordering::equivalent 相同。
const Qt::strong_ordering strong_ordering::equivalent
表示左操作数等于右操作数的比较结果。与Qt::strong_ordering::equal 相同。
const Qt::strong_ordering strong_ordering::greater
表示左操作数大于右操作数的比较结果。
const Qt::strong_ordering strong_ordering::less
表示左操作数小于右操作数的比较结果。
相关非成员
[constexpr noexcept]
bool is_eq(Qt::strong_ordering o)
[constexpr noexcept]
bool is_gt(Qt::strong_ordering o)
[constexpr noexcept]
bool is_gteq(Qt::strong_ordering o)
[constexpr noexcept]
bool is_lt(Qt::strong_ordering o)
[constexpr noexcept]
bool is_lteq(Qt::strong_ordering o)
[constexpr noexcept]
bool is_neq(Qt::strong_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::strong_ordering
兼容。
[constexpr noexcept]
bool operator!=(Qt::strong_ordering lhs, Qt::strong_ordering rhs)
如果lhs 和rhs 表示不同的结果,则返回 true;否则返回 true。
[constexpr noexcept]
bool operator==(Qt::strong_ordering lhs, Qt::strong_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.