Qt::strong_ordering Class
class Qt::strong_orderingQt::strong_ordering stellt einen Vergleich dar, bei dem gleichwertige Werte nicht voneinander zu unterscheiden sind. Mehr...
| Überschrift: | #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) | |
| operator Qt::partial_ordering() const | |
| operator Qt::weak_ordering() const | |
| 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) |
Ausführliche Beschreibung
Eine Drei-Wege-Vergleichsfunktion gibt typischerweise einen Wert vom Typ „ Qt::strong_ordering “ zurück. Eine solche Funktion vergleicht zwei Objekte und legt fest, wie diese geordnet sind. Sie verwendet diesen Rückgabetyp, um anzuzeigen, dass die Ordnung streng ist; das heißt, die Funktion legt eine wohldefinierte Gesamtordnung fest.
Qt::strong_ordering hat vier Werte, die durch die folgenden symbolischen Konstanten dargestellt werden:
- less bedeutet, dass der linke Operand kleiner ist als der rechte;
- equal bedeutet, dass der linke Operand gleich dem rechten ist;
- equivalent ist ein Alias für `
equal`; - greater bedeutet, dass der linke Operand größer ist als der rechte.
Qt::strong_ordering wird idiomatisch verwendet, indem eine Instanz mit dem Literal Null verglichen wird, zum Beispiel so:
// 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 zu Mitgliedsfunktionen
[constexpr noexcept] strong_ordering::strong_ordering(std::strong_ordering stdorder)
Erstellt ein ` Qt::strong_ordering `-Objekt aus ` stdorder ` unter Anwendung der folgenden Regeln:
- std::strong_ordering::less wird in less umgewandelt.
- std::strong_ordering::equivalent wird in equivalent konvertiert.
- std::strong_ordering::equal wird in „ equal “ konvertiert.
- „std::strong_ordering::greater“ wird in „ greater “ konvertiert.
[constexpr noexcept] strong_ordering::operator Qt::partial_ordering() const
Wandelt diesen „ Qt::strong_ordering “-Wert unter Anwendung der folgenden Regeln in ein „ Qt::partial_ordering “-Objekt um:
- less Wird in „ Qt::partial_ordering::less “ umgewandelt.
- equivalent Wird in ` Qt::partial_ordering::equivalent` konvertiert.
- equal Wird in „ Qt::partial_ordering::equivalent “ konvertiert.
- greater wird in „ Qt::partial_ordering::greater “ konvertiert.
[constexpr noexcept] strong_ordering::operator Qt::weak_ordering() const
Wandelt diesen Wert „ Qt::strong_ordering “ unter Verwendung der folgenden Regeln in ein „ Qt::weak_ordering “-Objekt um:
- less Wird in „ Qt::weak_ordering::less “ umgewandelt.
- equivalent Wird in „ Qt::weak_ordering::equivalent “ konvertiert.
- equal Wird in „ Qt::weak_ordering::equivalent “ konvertiert.
- greater wird in „ Qt::weak_ordering::greater “ konvertiert.
[constexpr noexcept] strong_ordering::operator std::strong_ordering() const
Konvertiert diesen Wert vom Typ „ Qt::strong_ordering “ unter Anwendung der folgenden Regeln in ein Objekt vom Typ „std::strong_ordering“:
- less wird in `std::strong_ordering::less` konvertiert.
- equivalent Wird in `std::strong_ordering::equivalent` umgewandelt.
- equal Wird in `std::strong_ordering::equal` konvertiert.
- greater Wird in `std::strong_ordering::greater` konvertiert.
Dokumentation zu den Member-Variablen
const Qt::strong_ordering strong_ordering::equal
Stellt das Ergebnis eines Vergleichs dar, bei dem der linke Operand gleich dem rechten Operand ist. Entspricht „ 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 Operand ist. Entspricht „ Qt::strong_ordering::equal “.
const Qt::strong_ordering strong_ordering::greater
Stellt das Ergebnis eines Vergleichs dar, bei dem der linke Operand größer ist als der rechte Operand.
const Qt::strong_ordering strong_ordering::less
Stellt das Ergebnis eines Vergleichs dar, bei dem der linke Operand kleiner ist als der rechte Operand.
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)
Wandelt ` o ` in das Ergebnis eines der sechs relationalen Operatoren um:
| 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 “ dasselbe Ergebnis liefern; andernfalls wird „false“ zurückgegeben.
© 2026 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.