Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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)
 

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

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:400
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
const GLubyte * c
GLuint64EXT * result
[6]
static int compare(quint64 a, quint64 b)

Definition at line 399 of file qcompare.h.

Member Function Documentation

◆ operator partial_ordering()

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

Definition at line 407 of file qcompare.h.

◆ operator weak_ordering()

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

Definition at line 410 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 579 of file qcompare.h.

◆ is_gt

constexpr bool is_gt ( strong_ordering o)
friend

Definition at line 583 of file qcompare.h.

◆ is_gteq

constexpr bool is_gteq ( strong_ordering o)
friend

Definition at line 584 of file qcompare.h.

◆ is_lt

constexpr bool is_lt ( strong_ordering o)
friend

Definition at line 581 of file qcompare.h.

◆ is_lteq

constexpr bool is_lteq ( strong_ordering o)
friend

Definition at line 582 of file qcompare.h.

◆ is_neq

constexpr bool is_neq ( strong_ordering o)
friend

Definition at line 580 of file qcompare.h.

◆ operator!= [1/7]

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

Definition at line 489 of file qcompare.h.

◆ operator!= [2/7]

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

Definition at line 442 of file qcompare.h.

◆ operator!= [3/7]

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

Definition at line 483 of file qcompare.h.

◆ operator!= [4/7]

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

Definition at line 417 of file qcompare.h.

◆ operator!= [5/7]

bool Qt::strong_ordering::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 477 of file qcompare.h.

◆ operator!= [6/7]

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

Definition at line 495 of file qcompare.h.

◆ operator!= [7/7]

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

Definition at line 501 of file qcompare.h.

◆ operator< [1/2]

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

Definition at line 446 of file qcompare.h.

◆ operator< [2/2]

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

Definition at line 421 of file qcompare.h.

◆ operator<= [1/2]

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

Definition at line 450 of file qcompare.h.

◆ operator<= [2/2]

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

Definition at line 425 of file qcompare.h.

◆ operator== [1/8]

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

Definition at line 486 of file qcompare.h.

◆ operator==() [2/8]

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

◆ operator== [3/8]

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

Definition at line 438 of file qcompare.h.

◆ operator== [4/8]

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

Definition at line 480 of file qcompare.h.

◆ operator== [5/8]

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

Definition at line 413 of file qcompare.h.

◆ operator== [6/8]

bool Qt::strong_ordering::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 474 of file qcompare.h.

◆ operator== [7/8]

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

Definition at line 492 of file qcompare.h.

◆ operator== [8/8]

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

Definition at line 498 of file qcompare.h.

◆ operator> [1/2]

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

Definition at line 454 of file qcompare.h.

◆ operator> [2/2]

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

Definition at line 429 of file qcompare.h.

◆ operator>= [1/2]

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

Definition at line 458 of file qcompare.h.

◆ operator>= [2/2]

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

Definition at line 433 of file qcompare.h.

Member Data Documentation

◆ equal

constexpr strong_ordering Qt::strong_ordering::equal
inlinestaticconstexpr

Definition at line 404 of file qcompare.h.

◆ equivalent

constexpr strong_ordering Qt::strong_ordering::equivalent
inlinestaticconstexpr

Definition at line 403 of file qcompare.h.

Referenced by Qt::compareThreeWay(), and Qt::compareThreeWay().

◆ greater

constexpr strong_ordering Qt::strong_ordering::greater
inlinestaticconstexpr

Definition at line 405 of file qcompare.h.

Referenced by Qt::compareThreeWay(), and Qt::compareThreeWay().

◆ less

constexpr strong_ordering Qt::strong_ordering::less
inlinestaticconstexpr

Definition at line 402 of file qcompare.h.

Referenced by Qt::compareThreeWay(), and Qt::compareThreeWay().


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