このページでは

Qt::weak_ordering Class

class Qt::weak_ordering

Qt::weak_ordering これは、等価な値であっても依然として区別できる場合の比較を表しています。詳細...

ヘッダー: #include <QtCompare>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
以下のように: Qt 6.7

パブリック関数

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

静的パブリックメンバー

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)

詳細な説明

Qt::weak_ordering 型の値は、通常、3 項比較関数から返されます。この関数は 2 つのオブジェクトを比較し、それらの順序を決定します。この戻り値の型は、順序付けが「弱い」こと、つまり同等の値でも区別される場合があることを示すために使用されます。

Qt::weak_ordering には3つの値があり、以下のシンボリック定数で表されます:

  • less は、左オペランドが右オペランドより小さいことを表します。
  • equivalent 左オペランドが右オペランドと等価であることを表します;
  • greater 左オペランドが右オペランドより大きいことを表します。

Qt::weak_ordering 慣例的には、インスタンスをリテラルゼロと比較する際に使用されます。例えば、次のようにします:

// 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
}

「 Qt::strong_ordering 」、「Qt::partial_ordering 」、および「比較型の概要」も参照してください 。

メンバ関数のドキュメント

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

stdorder から、以下のルールに従ってQt::weak_ordering オブジェクトを生成します。

  • std::weak_ordering::less はless に変換されます。
  • std::weak_ordering::equivalent はequivalent に変換されます。
  • std::weak_ordering::greater は、greater に変換されます。

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

この `Qt::weak_ordering ` 値を、以下のルールに従って `Qt::partial_ordering ` オブジェクトに変換します。

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

この `Qt::weak_ordering ` の値を、以下の規則に従って `std::weak_ordering` オブジェクトに変換します:

  • less std::weak_ordering::less に変換されます。
  • equivalent std::weak_ordering::equivalent に変換します。
  • greater std::weak_ordering::greater に変換します。

メンバ変数のドキュメント

const Qt::weak_ordering weak_ordering::equivalent

左側のオペランドが右側のオペランドと等価であるという比較の結果を表します。

const Qt::weak_ordering weak_ordering::greater

左側のオペランドが右側のオペランドより大きいという比較の結果を表します。

const Qt::weak_ordering weak_ordering::less

左側のオペランドが右側のオペランドより小さいという比較の結果を表します。

関連する非メンバー

[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)

o を、6つの関係演算子のいずれかの結果に変換します:

関数演算
is_eqo == 0
is_neqo != 0
is_lto < 0
is_lteqo <= 0
is_gto > 0
is_gteqo >= 0

これらの関数は、std::weak_ordering との互換性を確保するために提供されています。

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

lhs とrhs が異なる結果を表す場合は true を返し、そうでない場合は true を返します。

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

lhs とrhs が同じ結果を表す場合は true を返し、そうでない場合は false を返します。

© 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.