Auf dieser Seite

Qt::weak_ordering Class

class Qt::weak_ordering

Qt::weak_ordering stellt einen Vergleich dar, bei dem gleichwertige Werte dennoch unterscheidbar 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

weak_ordering(std::weak_ordering stdorder)
operator Qt::partial_ordering() const
operator std::weak_ordering() const

Statische öffentliche Mitglieder

const Qt::weak_ordering equivalent
const Qt::weak_ordering greater
const Qt::weak_ordering less
bool is_eq(Qt::weak_ordering o)
bool is_gt(Qt::weak_ordering o)
bool is_gteq(Qt::weak_ordering o)
bool is_lt(Qt::weak_ordering o)
bool is_lteq(Qt::weak_ordering o)
bool is_neq(Qt::weak_ordering o)
bool operator!=(Qt::weak_ordering lhs, Qt::weak_ordering rhs)
bool operator==(Qt::weak_ordering lhs, Qt::weak_ordering rhs)

Ausführliche Beschreibung

Eine Drei-Wege-Vergleichsfunktion gibt in der Regel einen Wert vom Typ „ Qt::weak_ordering “ zurück. Eine solche Funktion vergleicht zwei Objekte und legt fest, wie diese angeordnet sind. Sie verwendet diesen Rückgabetyp, um anzugeben, dass es sich um eine schwache Ordnung handelt; das heißt, gleichwertige Werte können unterscheidbar sein.

Qt::weak_ordering hat drei Werte, die durch die folgenden symbolischen Konstanten dargestellt werden:

  • less bedeutet, dass der linke Operand kleiner ist als der rechte;
  • equivalent bedeutet, dass der linke Operand dem rechten entspricht;
  • greater bedeutet, dass der linke Operand größer ist als der rechte;

Qt::weak_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::weak_ordering compare(T lhs, T rhs); // defined out-of-line
~~~

Qt::weak_ordering result = compare(a, b);
if (result < 0) {
    // a is less than b
}

if (compare(c, d) >= 0) {
    // c is greater than or equivalent to d
}

Siehe auch „ Qt::strong_ordering “, „ Qt::partial_ordering “ und „Übersicht über Vergleichstypen“.

Dokumentation zu Mitgliedsfunktionen

[constexpr noexcept] weak_ordering::weak_ordering(std::weak_ordering stdorder)

Erstellt ein ` Qt::weak_ordering `-Objekt aus ` stdorder ` unter Anwendung der folgenden Regeln:

  • „std::weak_ordering::less“ wird in „ less “ konvertiert.
  • std::weak_ordering::equivalent wird in „ equivalent “ umgewandelt.
  • std::weak_ordering::greater wird in „ greater “ umgewandelt.

[constexpr noexcept] weak_ordering::operator Qt::partial_ordering() const

Wandelt diesen Wert „ Qt::weak_ordering “ unter Anwendung der folgenden Regeln in ein „ Qt::partial_ordering “-Objekt um:

[constexpr noexcept] weak_ordering::operator std::weak_ordering() const

Wandelt diesen Wert vom Typ „ Qt::weak_ordering “ unter Anwendung der folgenden Regeln in ein Objekt vom Typ „std::weak_ordering“ um:

  • less Wird in `std::weak_ordering::less` umgewandelt.
  • equivalent Wird in `std::weak_ordering::equivalent` konvertiert.
  • greater Wird in `std::weak_ordering::greater` umgewandelt.

Dokumentation zu Membervariablen

const Qt::weak_ordering weak_ordering::equivalent

Stellt das Ergebnis eines Vergleichs dar, bei dem der linke Operand dem rechten Operand entspricht.

const Qt::weak_ordering weak_ordering::greater

Stellt das Ergebnis eines Vergleichs dar, bei dem der linke Operand größer ist als der rechte Operand.

const Qt::weak_ordering weak_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::weak_ordering o)

[constexpr noexcept] bool is_gt(Qt::weak_ordering o)

[constexpr noexcept] bool is_gteq(Qt::weak_ordering o)

[constexpr noexcept] bool is_lt(Qt::weak_ordering o)

[constexpr noexcept] bool is_lteq(Qt::weak_ordering o)

[constexpr noexcept] bool is_neq(Qt::weak_ordering o)

Wandelt „ o “ in das Ergebnis eines der sechs relationalen Operatoren um:

FunktionOperation
is_eqo == 0
is_neqo != 0
is_lto < 0
is_lteqo <= 0
is_gto > 0
is_gteqo >= 0

Diese Funktionen werden aus Kompatibilitätsgründen mit „ std::weak_ordering “ bereitgestellt.

[constexpr noexcept] bool operator!=(Qt::weak_ordering lhs, Qt::weak_ordering rhs)

Gibt „true“ zurück, wenn lhs und rhs unterschiedliche Ergebnisse darstellen; andernfalls wird „true“ zurückgegeben.

[constexpr noexcept] bool operator==(Qt::weak_ordering lhs, Qt::weak_ordering rhs)

Gibt „true“ zurück, wenn „ lhs “ und „ rhs “ dasselbe Ergebnis darstellen; 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.