- Qt 6.8
- Qt Core
- C++ Classes
- partial_ordering
- Qt 6.8.3 Reference Documentation

# partial_ordering Class

class Qt::partial_ordering

Qt::partial_ordering represents the result of a comparison that allows for unordered results. More...

Header: | `#include <QtCompare>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Core)` `target_link_libraries(mytarget PRIVATE Qt6::Core)`
qmake: | `QT += core`
Since: | Qt 6.7

- List of all members, including inherited members

## Public Functions

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

## Static Public Members

const Qt::partial_ordering | equivalent
const Qt::partial_ordering | greater
const Qt::partial_ordering | less
const Qt::partial_ordering | unordered

## Related Non-Members

bool | is_eq(Qt::partial_ordering o)
bool | is_gt(Qt::partial_ordering o)
bool | is_gteq(Qt::partial_ordering o)
bool | is_lt(Qt::partial_ordering o)
bool | is_lteq(Qt::partial_ordering o)
bool | is_neq(Qt::partial_ordering o)
bool | operator!=(Qt::partial_ordering lhs, Qt::partial_ordering rhs)
bool | operator==(Qt::partial_ordering lhs, Qt::partial_ordering rhs)

## Detailed Description

A value of type Qt::partial_ordering 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.

Qt::partial_ordering has four values, represented by the following symbolic constants:

- less represents that the left operand is less than the right;
- equivalent represents that the two operands are equivalent;
- greater represents that the left operand is greater than the right;
- unordered represents that the two operands are not ordered.

Qt::partial_ordering 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:

     Qt::partial_ordering compare(T lhs, T rhs); // defined out-of-line
     ~~~

     Qt::partial_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
     }

Comparing Qt::partial_ordering::unordered against literal 0 always returns a `false` result.

See also Qt::strong_ordering, Qt::weak_ordering, and Comparison types overview.

## Member Function Documentation

### `[constexpr noexcept]` partial_ordering::partial_ordering(std::partial_ordering stdorder)

Constructs a Qt::partial_ordering object from stdorder using the following rules:

- std::partial_ordering::less converts to less.
- std::partial_ordering::equivalent converts to equivalent.
- std::partial_ordering::greater converts to greater.
- std::partial_ordering::unordered converts to unordered

### `[constexpr noexcept]` std::partial_ordering partial_ordering::operator std::partial_ordering() const

Converts this Qt::partial_ordering value to a std::partial_ordering object using the following rules:

- less converts to std::partial_ordering::less.
- equivalent converts to std::partial_ordering::equivalent.
- greater converts to std::partial_ordering::greater.
- unordered converts to std::partial_ordering::unordered.

## Member Variable Documentation

### const Qt::partial_ordering partial_ordering::equivalent

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

### const Qt::partial_ordering partial_ordering::greater

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

### const Qt::partial_ordering partial_ordering::less

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

### const Qt::partial_ordering partial_ordering::unordered

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

## Related Non-Members

### `[constexpr noexcept]` bool is_eq(Qt::partial_ordering o)

### `[constexpr noexcept]` bool is_gt(Qt::partial_ordering o)

### `[constexpr noexcept]` bool is_gteq(Qt::partial_ordering o)

### `[constexpr noexcept]` bool is_lt(Qt::partial_ordering o)

### `[constexpr noexcept]` bool is_lteq(Qt::partial_ordering o)

### `[constexpr noexcept]` bool is_neq(Qt::partial_ordering o)

Converts o into the result of one of the six relational operators:

Function | 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`

These functions are provided for compatibility with `std::partial_ordering`.

### `[constexpr noexcept]` bool operator!=(Qt::partial_ordering lhs, Qt::partial_ordering rhs)

Return true if lhs and rhs represent different results; otherwise, returns true.

### `[constexpr noexcept]` bool operator==(Qt::partial_ordering lhs, Qt::partial_ordering rhs)

Return true if lhs and rhs represent the same result; otherwise, returns false.