strong_ordering Class
class Qt::strong_orderingQt::strong_ordering stellt einen Vergleich dar, bei dem äquivalente Werte ununterscheidbar sind. Mehr...
Kopfzeile: | #include <QtCompare> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
Seit: | Qt 6.7 |
Öffentliche Funktionen
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 |
Statische öffentliche Mitglieder
const Qt::strong_ordering | equal |
const Qt::strong_ordering | equivalent |
const Qt::strong_ordering | greater |
const Qt::strong_ordering | less |
Verwandte Nicht-Mitglieder
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) |
Detaillierte Beschreibung
Ein Wert vom Typ Qt::strong_ordering wird in der Regel von einer Drei-Wege-Vergleichsfunktion zurückgegeben. Eine solche Funktion vergleicht zwei Objekte und stellt fest, wie sie geordnet sind. Sie verwendet diesen Rückgabetyp, um anzuzeigen, dass die Ordnung strikt ist, d.h. die Funktion stellt eine wohldefinierte Gesamtordnung her.
Qt::strong_ordering hat vier Werte, die durch die folgenden symbolischen Konstanten dargestellt werden:
- less steht dafür, dass der linke Operand kleiner ist als der rechte;
- equal steht dafür, dass der linke Operand gleich dem rechten ist;
- equivalent ist ein Alias für
equal
; - greater steht dafür, dass der linke Operand größer ist als der rechte.
Qt::strong_ordering wird idiomatisch verwendet, indem eine Instanz mit einer literalen Null verglichen wird, z. B. wie hier:
// 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 }
Siehe auch Qt::weak_ordering, Qt::partial_ordering, und Übersicht über Vergleichstypen.
Dokumentation der Mitgliedsfunktionen
[constexpr noexcept]
strong_ordering::strong_ordering(std::strong_ordering stdorder)
Konstruiert ein Qt::strong_ordering Objekt aus stdorder unter Verwendung der folgenden Regeln:
- std::strong_ordering::less konvertiert in less.
- std::strong_ordering::equivalent wandelt in equivalent um.
- std::strong_ordering::equal konvertiert nach equal.
- std::strong_ordering::greater konvertiert nach greater.
[constexpr noexcept]
Qt::partial_ordering strong_ordering::operator Qt::partial_ordering() const
Konvertiert diesen Qt::strong_ordering Wert in ein Qt::partial_ordering Objekt unter Verwendung der folgenden Regeln:
- less konvertiert in Qt::partial_ordering::less.
- equivalent konvertiert nach Qt::partial_ordering::equivalent.
- equal konvertiert nach Qt::partial_ordering::equivalent.
- greater konvertiert in Qt::partial_ordering::greater.
[constexpr noexcept]
Qt::weak_ordering strong_ordering::operator Qt::weak_ordering() const
Konvertiert diesen Qt::strong_ordering Wert in ein Qt::weak_ordering Objekt unter Verwendung der folgenden Regeln:
- less konvertiert in Qt::weak_ordering::less.
- equivalent konvertiert nach Qt::weak_ordering::equivalent.
- equal konvertiert nach Qt::weak_ordering::equivalent.
- greater konvertiert in Qt::weak_ordering::greater.
[constexpr noexcept]
std::strong_ordering strong_ordering::operator std::strong_ordering() const
Konvertiert diesen Wert Qt::strong_ordering in ein std::strong_ordering-Objekt unter Anwendung der folgenden Regeln:
- less konvertiert in std::strong_ordering::less.
- equivalent konvertiert nach std::strong_ordering::equivalent.
- equal konvertiert nach std::strong_ordering::equal.
- greater konvertiert nach std::strong_ordering::greater.
Dokumentation der Mitgliedsvariablen
const Qt::strong_ordering strong_ordering::equal
Stellt das Ergebnis eines Vergleichs dar, bei dem der linke Operand gleich dem rechten Operanden ist. Dasselbe wie Qt::strong_ordering::equivalent.
const Qt::strong_ordering strong_ordering::equivalent
Stellt das Ergebnis eines Vergleichs dar, bei dem der linke Operand gleich dem rechten Operanden ist. Dasselbe wie Qt::strong_ordering::equal.
const Qt::strong_ordering strong_ordering::greater
Stellt das Ergebnis eines Vergleichs dar, bei dem der linke Operand größer als der rechte Operand ist.
const Qt::strong_ordering strong_ordering::less
Stellt das Ergebnis eines Vergleichs dar, bei dem der linke Operand kleiner als der rechte Operand ist.
Verwandte Nicht-Mitglieder
[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)
Konvertiert o in das Ergebnis eines der sechs relationalen Operatoren:
Funktion | Operation |
---|---|
is_eq | o == 0 |
is_neq | o != 0 |
is_lt | o < 0 |
is_lteq | o <= 0 |
is_gt | o > 0 |
is_gteq | o >= 0 |
Diese Funktionen werden aus Gründen der Kompatibilität mit std::strong_ordering
bereitgestellt.
[constexpr noexcept]
bool operator!=(Qt::strong_ordering lhs, Qt::strong_ordering rhs)
Gibt true zurück, wenn lhs und rhs unterschiedliche Ergebnisse darstellen; andernfalls wird true zurückgegeben.
[constexpr noexcept]
bool operator==(Qt::strong_ordering lhs, Qt::strong_ordering rhs)
Gibt true zurück, wenn lhs und rhs das gleiche Ergebnis darstellen; andernfalls wird false zurückgegeben.
© 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.