QPartialOrdering 类

QPartialOrdering 表示允许用于无序结果的比较结果。 更多...

头: #include <QPartialOrdering>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Since: Qt 6.0

静态公共成员

const QPartialOrdering Equivalent
const QPartialOrdering Greater
const QPartialOrdering Less
const QPartialOrdering Unordered
bool operator!= (QPartialOrdering lhs , QPartialOrdering rhs )
bool operator== (QPartialOrdering lhs , QPartialOrdering rhs )

详细描述

A value of type QPartialOrdering is typically returned from a three-way comparison function. Such a function compares two objects, and it may either establish that the two objects are ordered relative to each other, or that they are not ordered. The QPartialOrdering value returned from the comparison function represents one of those possibilities.

The possible values of type QPartialOrdering are, in fact, fully represented by the following four static values:

  • QPartialOrdering::Less represents that the first object is less than the second;
  • QPartialOrdering::Equivalent represents that the first object is equivalent to the second;
  • QPartialOrdering::Greater represents that the first object is greater than the second;
  • QPartialOrdering::Unordered represents that the first object is not ordered with respect to the second.

QPartialOrdering is idiomatically used by comparing an instance against a literal zero, for instance like this:

// given a, b, c, d as objects of some type that allows for a 3-way compare,
// and a compare function declared as follows:
QPartialOrdering compare(T lhs, T rhs); // defined out-of-line
~~~
QPartialOrdering 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
}
					

A QPartialOrdering value which represents an unordered result will always return false when compared against literal 0.

成员变量文档编制

const QPartialOrdering QPartialOrdering:: Equivalent

Represents the result of a comparison where the value on the left hand side is equivalent to the value on the right hand side.

const QPartialOrdering QPartialOrdering:: Greater

Represents the result of a comparison where the value on the left hand side is greater than the value on the right hand side.

const QPartialOrdering QPartialOrdering:: Less

Represents the result of a comparison where the value on the left hand side is less than the value on the right hand side.

const QPartialOrdering QPartialOrdering:: Unordered

Represents the result of a comparison where the value on the left hand side is not ordered with respect to the value on the right hand side.

相关非成员

[constexpr] bool operator!= ( QPartialOrdering lhs , QPartialOrdering rhs )

返回 True 若 lhs and rhs represent different results; otherwise, returns true.

[constexpr] bool operator== ( QPartialOrdering lhs , QPartialOrdering rhs )

返回 True 若 lhs and rhs represent the same result; otherwise, returns false.