Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qcompare.qdoc
Go to the documentation of this file.
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
3
4/*!
5 \class QPartialOrdering
6 \inmodule QtCore
7 \brief QPartialOrdering represents the result of a comparison that allows for unordered results.
8 \since 6.0
9
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.
16
17 The possible values of type QPartialOrdering are, in fact, fully
18 represented by the following four static values:
19
20 \list
21 \li \c QPartialOrdering::Less represents that the first object is
22 less than the second;
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.
29 \endlist
30
31 QPartialOrdering is idiomatically used by comparing an instance
32 against a literal zero, for instance like this:
33
34 \code
35
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:
38
39 QPartialOrdering compare(T lhs, T rhs); // defined out-of-line
40 ~~~
41
42 QPartialOrdering result = compare(a, b);
43 if (result < 0) {
44 // a is less than b
45 }
46
47 if (compare(c, d) >= 0) {
48 // c is greater than or equal to d
49 }
50
51 \endcode
52
53 A QPartialOrdering value which represents an unordered result will
54 always return false when compared against literal 0.
55*/
56
57/*!
58 \fn bool QPartialOrdering::operator==(QPartialOrdering lhs, QPartialOrdering rhs)
59
60 Return true if \a lhs and \a rhs represent the same result;
61 otherwise, returns false.
62*/
63
64/*!
65 \fn bool QPartialOrdering::operator!=(QPartialOrdering lhs, QPartialOrdering rhs)
66
67 Return true if \a lhs and \a rhs represent different results;
68 otherwise, returns true.
69*/
70
71/*!
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)
78
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
86 \internal
87*/
88
89/*!
90 \variable QPartialOrdering::Less
91
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.
94*/
95
96/*!
97 \variable QPartialOrdering::Equivalent
98
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.
101*/
102
103/*!
104 \variable QPartialOrdering::Greater
105
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.
108*/
109
110/*!
111 \variable QPartialOrdering::Unordered
112
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
115 side.
116*/