Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
Qt::strong_ordering Class Reference

\inmodule QtCore \title Classes and helpers for defining comparison operators \keyword qtcompare More...

#include <qcompare.h>

+ Collaboration diagram for Qt::strong_ordering:

Public Member Functions

constexpr Q_IMPLICIT operator partial_ordering () const noexcept
 
constexpr Q_IMPLICIT operator weak_ordering () const noexcept
 

Static Public Attributes

static const strong_ordering less
 
static const strong_ordering equivalent
 
static const strong_ordering equal
 
static const strong_ordering greater
 

Friends

constexpr bool operator== (strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
 
constexpr bool operator!= (strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
 
constexpr bool operator< (strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
 
constexpr bool operator<= (strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
 
constexpr bool operator> (strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
 
constexpr bool operator>= (strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
 
constexpr bool operator== (QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) noexcept
 
constexpr bool operator!= (QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) noexcept
 
constexpr bool operator< (QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) noexcept
 
constexpr bool operator<= (QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) noexcept
 
constexpr bool operator> (QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) noexcept
 
constexpr bool operator>= (QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) noexcept
 
constexpr bool operator== (strong_ordering lhs, strong_ordering rhs) noexcept
 Returns true if lhs and rhs represent the same result; otherwise, returns false.
 
constexpr bool operator!= (strong_ordering lhs, strong_ordering rhs) noexcept
 Returns true if lhs and rhs represent different results; otherwise, returns true.
 
constexpr bool operator== (strong_ordering lhs, partial_ordering rhs) noexcept
 
constexpr bool operator!= (strong_ordering lhs, partial_ordering rhs) noexcept
 
constexpr bool operator== (partial_ordering lhs, strong_ordering rhs) noexcept
 
constexpr bool operator!= (partial_ordering lhs, strong_ordering rhs) noexcept
 
constexpr bool operator== (strong_ordering lhs, weak_ordering rhs) noexcept
 
constexpr bool operator!= (strong_ordering lhs, weak_ordering rhs) noexcept
 
constexpr bool operator== (weak_ordering lhs, strong_ordering rhs) noexcept
 
constexpr bool operator!= (weak_ordering lhs, strong_ordering rhs) noexcept
 
QT_WARNING_PUSH friend constexpr bool is_eq (strong_ordering o) noexcept
 
constexpr bool is_neq (strong_ordering o) noexcept
 
constexpr bool is_lt (strong_ordering o) noexcept
 
constexpr bool is_lteq (strong_ordering o) noexcept
 
constexpr bool is_gt (strong_ordering o) noexcept
 
constexpr bool is_gteq (strong_ordering o) noexcept
 

Related Symbols

(Note that these are not member symbols.)

bool operator== (Qt::strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero)
 
bool operator== (Qt::strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero)
 

Detailed Description

\inmodule QtCore \title Classes and helpers for defining comparison operators \keyword qtcompare

The <QtCompare> header file defines {Qt::*_ordering} types and helper macros for defining comparison operators.

This header introduces the \l Qt::partial_ordering, \l Qt::weak_ordering, and \l Qt::strong_ordering types, which are Qt's C++17 backports of {std::*_ordering} types.

This header also contains functions for implementing three-way comparison in C++17.

The {Qt::compareThreeWay()} function overloads provide three-way comparison for built-in C++ types.

The \l qCompareThreeWay() template serves as a generic three-way comparison implementation. It relies on {Qt::compareThreeWay()} and free {compareThreeWay()} functions in its implementation.

\inmodule QtCore \inheaderfile QtCompare

Qt::strong_ordering represents a comparison where equivalent values are indistinguishable.

See also
Qt::weak_ordering, Qt::partial_ordering, {Comparison types overview}
Since
6.7

A value of type Qt::strong_ordering is typically returned from a three-way comparison function. Such a function compares two objects and establishes how they are ordered. It uses this return type to indicate that the ordering is strict; that is, the function establishes a well-defined total order.

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

\list

  • \l less represents that the left operand is less than the right;
  • \l equal represents that the left operand is equivalent to the right;
  • \l equivalent is an alias for equal;
  • \l greater represents that the left operand is greater than the right. \endlist

Qt::strong_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::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
}
\inmodule QtCore \title Classes and helpers for defining comparison operators \keyword qtcompare
Definition qcompare.h:442
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
const GLubyte * c
GLuint64EXT * result
[6]
static int compare(quint64 a, quint64 b)
double d
[1]

Definition at line 441 of file qcompare.h.

Member Function Documentation

◆ operator partial_ordering()

Q_IMPLICIT Qt::strong_ordering::operator partial_ordering ( ) const
inlineconstexprnoexcept

Definition at line 449 of file qcompare.h.

◆ operator weak_ordering()

Q_IMPLICIT Qt::strong_ordering::operator weak_ordering ( ) const
inlineconstexprnoexcept

Definition at line 452 of file qcompare.h.

Friends And Related Symbol Documentation

◆ is_eq

QT_WARNING_PUSH friend constexpr bool is_eq ( strong_ordering o)
friend

Definition at line 622 of file qcompare.h.

◆ is_gt

bool is_gt ( strong_ordering o)
friend

Definition at line 626 of file qcompare.h.

◆ is_gteq

bool is_gteq ( strong_ordering o)
friend

Definition at line 627 of file qcompare.h.

◆ is_lt

bool is_lt ( strong_ordering o)
friend

Definition at line 624 of file qcompare.h.

◆ is_lteq

bool is_lteq ( strong_ordering o)
friend

Definition at line 625 of file qcompare.h.

◆ is_neq

bool is_neq ( strong_ordering o)
friend

Definition at line 623 of file qcompare.h.

◆ operator!= [1/7]

bool operator!= ( partial_ordering lhs,
strong_ordering rhs )
friend

Definition at line 531 of file qcompare.h.

◆ operator!= [2/7]

bool operator!= ( QtPrivate::CompareAgainstLiteralZero ,
strong_ordering rhs )
friend

Definition at line 484 of file qcompare.h.

◆ operator!= [3/7]

bool operator!= ( strong_ordering lhs,
partial_ordering rhs )
friend

Definition at line 525 of file qcompare.h.

◆ operator!= [4/7]

bool operator!= ( strong_ordering lhs,
QtPrivate::CompareAgainstLiteralZero  )
friend

Definition at line 459 of file qcompare.h.

◆ operator!= [5/7]

bool operator!= ( Qt::strong_ordering lhs,
Qt::strong_ordering rhs )
friend

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

Definition at line 519 of file qcompare.h.

◆ operator!= [6/7]

bool operator!= ( strong_ordering lhs,
weak_ordering rhs )
friend

Definition at line 537 of file qcompare.h.

◆ operator!= [7/7]

bool operator!= ( weak_ordering lhs,
strong_ordering rhs )
friend

Definition at line 543 of file qcompare.h.

◆ operator< [1/2]

bool operator< ( QtPrivate::CompareAgainstLiteralZero ,
strong_ordering rhs )
friend

Definition at line 488 of file qcompare.h.

◆ operator< [2/2]

bool operator< ( strong_ordering lhs,
QtPrivate::CompareAgainstLiteralZero  )
friend

Definition at line 463 of file qcompare.h.

◆ operator<= [1/2]

bool operator<= ( QtPrivate::CompareAgainstLiteralZero ,
strong_ordering rhs )
friend

Definition at line 492 of file qcompare.h.

◆ operator<= [2/2]

bool operator<= ( strong_ordering lhs,
QtPrivate::CompareAgainstLiteralZero  )
friend

Definition at line 467 of file qcompare.h.

◆ operator== [1/9]

bool operator== ( partial_ordering lhs,
strong_ordering rhs )
friend

Definition at line 528 of file qcompare.h.

◆ operator==() [2/9]

bool operator== ( Qt::strong_ordering lhs,
QtPrivate::CompareAgainstLiteralZero  )
related

◆ operator==() [3/9]

bool operator== ( Qt::strong_ordering lhs,
QtPrivate::CompareAgainstLiteralZero  )
related

◆ operator== [4/9]

bool operator== ( QtPrivate::CompareAgainstLiteralZero ,
strong_ordering rhs )
friend

Definition at line 480 of file qcompare.h.

◆ operator== [5/9]

bool operator== ( strong_ordering lhs,
partial_ordering rhs )
friend

Definition at line 522 of file qcompare.h.

◆ operator== [6/9]

bool operator== ( strong_ordering lhs,
QtPrivate::CompareAgainstLiteralZero  )
friend

Definition at line 455 of file qcompare.h.

◆ operator== [7/9]

bool operator== ( Qt::strong_ordering lhs,
Qt::strong_ordering rhs )
friend

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

Definition at line 516 of file qcompare.h.

◆ operator== [8/9]

bool operator== ( strong_ordering lhs,
weak_ordering rhs )
friend

Definition at line 534 of file qcompare.h.

◆ operator== [9/9]

bool operator== ( weak_ordering lhs,
strong_ordering rhs )
friend

Definition at line 540 of file qcompare.h.

◆ operator> [1/2]

bool operator> ( QtPrivate::CompareAgainstLiteralZero ,
strong_ordering rhs )
friend

Definition at line 496 of file qcompare.h.

◆ operator> [2/2]

bool operator> ( strong_ordering lhs,
QtPrivate::CompareAgainstLiteralZero  )
friend

Definition at line 471 of file qcompare.h.

◆ operator>= [1/2]

bool operator>= ( QtPrivate::CompareAgainstLiteralZero ,
strong_ordering rhs )
friend

Definition at line 500 of file qcompare.h.

◆ operator>= [2/2]

bool operator>= ( strong_ordering lhs,
QtPrivate::CompareAgainstLiteralZero  )
friend

Definition at line 475 of file qcompare.h.

Member Data Documentation

◆ equal

strong_ordering Qt::strong_ordering::equal
inlinestaticconstexpr

Definition at line 446 of file qcompare.h.

◆ equivalent

strong_ordering Qt::strong_ordering::equivalent
inlinestaticconstexpr

Definition at line 445 of file qcompare.h.

◆ greater

strong_ordering Qt::strong_ordering::greater
inlinestaticconstexpr

Definition at line 447 of file qcompare.h.

◆ less

strong_ordering Qt::strong_ordering::less
inlinestaticconstexpr

Definition at line 444 of file qcompare.h.


The documentation for this class was generated from the following files: