QStrongOrdering Class
QStrongOrdering represents a comparison where equivalent values are indistinguishable. More...
Header: | #include <QStrongOrdering> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
Since: | Qt 6.6 |
Public Functions
QStrongOrdering(int stdorder) | |
QPartialOrdering | operator QPartialOrdering() const |
QWeakOrdering | operator QWeakOrdering() const |
Static Public Members
const QStrongOrdering | Equal |
const QStrongOrdering | Equivalent |
const QStrongOrdering | Greater |
const QStrongOrdering | Less |
Related Non-Members
bool | operator!=(QStrongOrdering lhs, QStrongOrdering rhs) |
bool | operator==(QStrongOrdering lhs, QStrongOrdering rhs) |
Detailed Description
A value of type QStrongOrdering is typically returned from a three-way comparison function. Such a function compares two objects and establishes that the two objects are in a strict ordering relationship; that is, the function establishes a well-defined total order.
The possible values of type QStrongOrdering are fully represented by the following four symbolic constants:
Less
represents that the left operand is less than the right;Equal
represents that the left operand is equivalent to the right;Equivalent
is an alias forEqual
;Greater
represents that the left operand is greater than the right.
QStrongOrdering 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: QStrongOrdering compare(T lhs, T rhs); // defined out-of-line ~~~ QStrongOrdering 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 }
See also QWeakOrdering, QPartialOrdering, and Comparison types overview.
Member Function Documentation
[default]
QStrongOrdering::QStrongOrdering(int stdorder)
Constructs a QStrongOrdering object from stdorder using the following rules:
- std::strong_ordering::less converts to Less.
- std::strong_ordering::equivalent converts to Equivalent.
- std::strong_ordering::equal converts to Equal.
- std::strong_ordering::greater converts to Greater.
[constexpr noexcept]
QPartialOrdering QStrongOrdering::operator QPartialOrdering() const
Converts this QStrongOrdering value to a QPartialOrdering object using the following rules:
- Less converts to QPartialOrdering::Less.
- Equivalent converts to QPartialOrdering::Equivalent.
- Equal converts to QPartialOrdering::Equivalent.
- Greater converts to QPartialOrdering::Greater.
[constexpr noexcept]
QWeakOrdering QStrongOrdering::operator QWeakOrdering() const
Converts this QStrongOrdering value to a QWeakOrdering object using the following rules:
- Less converts to QWeakOrdering::Less.
- Equivalent converts to QWeakOrdering::Equivalent.
- Equal converts to QWeakOrdering::Equivalent.
- Greater converts to QWeakOrdering::Greater.
Member Variable Documentation
const QStrongOrdering QStrongOrdering::Equal
Represents the result of a comparison where the left operand is equal to the right operand. Same as QStrongOrdering::Equivalent.
const QStrongOrdering QStrongOrdering::Equivalent
Represents the result of a comparison where the left operand is equal to the right operand. Same as QStrongOrdering::Equal.
const QStrongOrdering QStrongOrdering::Greater
Represents the result of a comparison where the left operand is greater than the right operand.
const QStrongOrdering QStrongOrdering::Less
Represents the result of a comparison where the left operand is less than the right operand.
Related Non-Members
[constexpr noexcept]
bool operator!=(QStrongOrdering lhs, QStrongOrdering rhs)
Returns true if lhs and rhs represent different results; otherwise, returns true.
[constexpr noexcept]
bool operator==(QStrongOrdering lhs, QStrongOrdering rhs)
Returns true if lhs and rhs represent the same result; otherwise, returns false.