QPartialOrdering 類

QPartialOrdering 錶示允許用於無序結果的比較結果。 更多...

頭: #include <QPartialOrdering>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Since: Qt 6.0

公共函數

QPartialOrdering (std::partial_ordering stdorder )
std::partial_ordering operator std::partial_ordering () const

靜態公共成員

const QPartialOrdering Equivalent
const QPartialOrdering Greater
const QPartialOrdering Less
const QPartialOrdering Unordered
const QPartialOrdering equivalent
const QPartialOrdering greater
const QPartialOrdering less
const QPartialOrdering unordered
(從 6.7 起) bool is_eq (QPartialOrdering o )
(從 6.7 起) bool is_gt (QPartialOrdering o )
(從 6.7 起) bool is_gteq (QPartialOrdering o )
(從 6.7 起) bool is_lt (QPartialOrdering o )
(從 6.7 起) bool is_lteq (QPartialOrdering o )
(從 6.7 起) bool is_neq (QPartialOrdering o )
bool operator!= (QPartialOrdering lhs , QPartialOrdering rhs )
bool operator== (QPartialOrdering lhs , QPartialOrdering rhs )

詳細描述

A value of type QPartialOrdering is typically returned from a three-way comparison function. Such a function compares two objects, establishing whether they are ordered and, if so, their ordering. It uses this return type to indicate that the ordering is partial; that is, not all pairs of values are ordered.

QPartialOrdering has four values, represented by the following symbolic constants:

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

比較 QPartialOrdering::unordered 針對文字 0 始終返迴 false 結果。

另請參閱 Qt::strong_ordering , Qt::weak_ordering ,和 比較類型概述 .

成員函數文檔編製

[constexpr noexcept] QPartialOrdering:: QPartialOrdering ( std::partial_ordering stdorder )

Constructs a QPartialOrdering object from stdorder 使用下列規則:

  • std::partial_ordering::less 轉換成 less .
  • std::partial_ordering::equivalent 轉換成 equivalent .
  • std::partial_ordering::greater 轉換成 greater .
  • std::partial_ordering::unordered 轉換成 unordered

[constexpr noexcept] std::partial_ordering QPartialOrdering:: operator std::partial_ordering () const

轉換此 QPartialOrdering value to a std::partial_ordering object using the following rules:

  • less 轉換成 std::partial_ordering::less。
  • equivalent 轉換成 std::partial_ordering::equivalent。
  • greater 轉換成 std::partial_ordering::greater。
  • unordered 轉換成 std::partial_ordering::unordered。

成員變量文檔編製

const QPartialOrdering QPartialOrdering:: Equivalent

Represents the result of a comparison where the two operands are equivalent.

const QPartialOrdering QPartialOrdering:: Greater

Represents the result of a comparison where the left operand is greater than the right operand.

const QPartialOrdering QPartialOrdering:: Less

Represents the result of a comparison where the left operand is less than the right operand.

const QPartialOrdering QPartialOrdering:: Unordered

Represents the result of a comparison where there is no ordering relationship between the two operands.

const QPartialOrdering QPartialOrdering:: equivalent

Represents the result of a comparison where the two operands are equivalent.

const QPartialOrdering QPartialOrdering:: greater

Represents the result of a comparison where the left operand is greater than the right operand.

const QPartialOrdering QPartialOrdering:: less

Represents the result of a comparison where the left operand is less than the right operand.

const QPartialOrdering QPartialOrdering:: unordered

Represents the result of a comparison where there is no ordering relationship between the two operands.

相關非成員

[constexpr noexcept, since 6.7] bool is_eq ( QPartialOrdering o )

[constexpr noexcept, since 6.7] bool is_gt ( QPartialOrdering o )

[constexpr noexcept, since 6.7] bool is_gteq ( QPartialOrdering o )

[constexpr noexcept, since 6.7] bool is_lt ( QPartialOrdering o )

[constexpr noexcept, since 6.7] bool is_lteq ( QPartialOrdering o )

[constexpr noexcept, since 6.7] bool is_neq ( QPartialOrdering o )

轉換 o into the result of one of the six relational operators:

函數 操作
is_eq o == 0
is_neq o != 0
is_lt o < 0
is_lteq o <= 0
is_gt o > 0
is_gteq o >= 0

提供這些函數是為兼容 std::partial_ordering .

該函數在 Qt 6.7 引入。

[constexpr noexcept] bool operator!= ( QPartialOrdering lhs , QPartialOrdering rhs )

返迴 True 若 lhs and rhs 錶示不同結果;否則,返迴 true。

[constexpr noexcept] bool operator== ( QPartialOrdering lhs , QPartialOrdering rhs )

返迴 True 若 lhs and rhs 錶示相同結果;否則,返迴 false。