1// Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5 \class QPartialOrdering
7 \brief QPartialOrdering represents the result of a comparison that allows for unordered results.
10 A value of type QPartialOrdering is typically returned from a
11 three-way comparison function. Such a function compares two
12 objects, and it may either establish that the two objects are
13 ordered relative to each other, or that they are not ordered. The
14 QPartialOrdering value returned from the comparison function
15 represents one of those possibilities.
17 The possible values of type QPartialOrdering are, in fact, fully
18 represented by the following four static values:
21 \li \c QPartialOrdering::Less represents that the first object is
23 \li \c QPartialOrdering::Equivalent represents that the first
24 object is equivalent to the second;
25 \li \c QPartialOrdering::Greater represents that the first object
26 is greater than the second;
27 \li \c QPartialOrdering::Unordered represents that the first object
28 is \e{not ordered} with respect to the second.
31 QPartialOrdering is idiomatically used by comparing an instance
32 against a literal zero, for instance like this:
36 // given a, b, c, d as objects of some type that allows for a 3-way compare,
37 // and a compare function declared as follows:
39 QPartialOrdering compare(T lhs, T rhs); // defined out-of-line
42 QPartialOrdering result = compare(a, b);
47 if (compare(c, d) >= 0) {
48 // c is greater than or equal to d
53 A QPartialOrdering value which represents an unordered result will
54 always return false when compared against literal 0.
58 \fn bool QPartialOrdering::operator==(QPartialOrdering lhs, QPartialOrdering rhs)
60 Return true if \a lhs and \a rhs represent the same result;
61 otherwise, returns false.
65 \fn bool QPartialOrdering::operator!=(QPartialOrdering lhs, QPartialOrdering rhs)
67 Return true if \a lhs and \a rhs represent different results;
68 otherwise, returns true.
72 \fn bool operator==(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero)
73 \fn bool operator!=(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero)
74 \fn bool operator< (QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero)
75 \fn bool operator<=(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero)
76 \fn bool operator> (QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero)
77 \fn bool operator>=(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero)
79 \fn bool operator==(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs)
80 \fn bool operator!=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs)
81 \fn bool operator< (QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs)
82 \fn bool operator<=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs)
83 \fn bool operator> (QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs)
84 \fn bool operator>=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs)
85 \relates QPartialOrdering
90 \variable QPartialOrdering::Less
92 Represents the result of a comparison where the value on the left
93 hand side is less than the value on the right hand side.
97 \variable QPartialOrdering::Equivalent
99 Represents the result of a comparison where the value on the left
100 hand side is equivalent to the value on the right hand side.
104 \variable QPartialOrdering::Greater
106 Represents the result of a comparison where the value on the left
107 hand side is greater than the value on the right hand side.
111 \variable QPartialOrdering::Unordered
113 Represents the result of a comparison where the value on the left
114 hand side is not ordered with respect to the value on the right hand