QPartialOrdering Class
QPartialOrdering represents the result of a comparison that allows for unordered results. More...
Header: | #include <QPartialOrdering> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
Since: | Qt 6.0 |
Public Functions
QPartialOrdering(int stdorder) |
Static Public Members
const QPartialOrdering | Equivalent |
const QPartialOrdering | Greater |
const QPartialOrdering | Less |
const QPartialOrdering | Unordered |
Related Non-Members
bool | operator!=(QPartialOrdering lhs, QPartialOrdering rhs) |
bool | operator==(QPartialOrdering lhs, QPartialOrdering rhs) |
Detailed Description
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 symbolic constants:
Less
represents that the left operand is less than the right;Equivalent
represents that left operand is equivalent to the right;Greater
represents that the left operand is greater than the right;Unordered
represents that the left operand is not ordered with respect to the right operand.
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.
See also QStrongOrdering, QWeakOrdering, and Comparison types overview.
Member Function Documentation
[default]
QPartialOrdering::QPartialOrdering(int stdorder)
Constructs a QPartialOrdering object from stdorder using the following rules:
- std::partial_ordering::less converts to Less.
- std::partial_ordering::equivalent converts to Equivalent.
- std::partial_ordering::greater converts to Greater.
- std::partial_ordering::unordered converts to Unordered
Member Variable Documentation
const QPartialOrdering QPartialOrdering::Equivalent
Represents the result of a comparison where the left operand is equivalent to the right operand.
const QPartialOrdering QPartialOrdering::Greater
Represents the result of a comparison where the left operand is greater than the right operand.
const QPartialOrdering QPartialOrdering::Less
Represents the result of a comparison where the left operand is less than the right operand.
const QPartialOrdering QPartialOrdering::Unordered
Represents the result of a comparison where the left operand is not ordered with respect to the right operand.
Related Non-Members
[constexpr noexcept]
bool operator!=(QPartialOrdering lhs, QPartialOrdering rhs)
Return true if lhs and rhs represent different results; otherwise, returns true.
[constexpr noexcept]
bool operator==(QPartialOrdering lhs, QPartialOrdering rhs)
Return true if lhs and rhs represent the same result; otherwise, returns false.