Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qcompare.h
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 LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCOMPARE_H
5#define QCOMPARE_H
6
7#if 0
8#pragma qt_class(QtCompare)
9#endif
10
11#include <QtCore/qglobal.h>
12#include <QtCore/qcompare_impl.h>
13
15
16namespace QtPrivate {
18
19// [cmp.categories.pre] / 1
21{
22 Equal = 0,
24 Less = -1,
25 Greater = 1
26};
27
29{
30 Unordered = -127
31};
32
33} // namespace QtPrivate
34
35// [cmp.partialord]
37{
38public:
39 static const QPartialOrdering Less;
43
44 friend constexpr bool operator==(QPartialOrdering lhs,
46 { return lhs.isOrdered() && lhs.m_order == 0; }
47
48 friend constexpr bool operator!=(QPartialOrdering lhs,
50 { return lhs.isOrdered() && lhs.m_order != 0; }
51
52 friend constexpr bool operator< (QPartialOrdering lhs,
54 { return lhs.isOrdered() && lhs.m_order < 0; }
55
56 friend constexpr bool operator<=(QPartialOrdering lhs,
58 { return lhs.isOrdered() && lhs.m_order <= 0; }
59
60 friend constexpr bool operator> (QPartialOrdering lhs,
62 { return lhs.isOrdered() && lhs.m_order > 0; }
63
64 friend constexpr bool operator>=(QPartialOrdering lhs,
66 { return lhs.isOrdered() && lhs.m_order >= 0; }
67
68
70 QPartialOrdering rhs) noexcept
71 { return rhs.isOrdered() && 0 == rhs.m_order; }
72
74 QPartialOrdering rhs) noexcept
75 { return rhs.isOrdered() && 0 != rhs.m_order; }
76
78 QPartialOrdering rhs) noexcept
79 { return rhs.isOrdered() && 0 < rhs.m_order; }
80
82 QPartialOrdering rhs) noexcept
83 { return rhs.isOrdered() && 0 <= rhs.m_order; }
84
86 QPartialOrdering rhs) noexcept
87 { return rhs.isOrdered() && 0 > rhs.m_order; }
88
90 QPartialOrdering rhs) noexcept
91 { return rhs.isOrdered() && 0 >= rhs.m_order; }
92
93
94 friend constexpr bool operator==(QPartialOrdering lhs, QPartialOrdering rhs) noexcept
95 { return lhs.m_order == rhs.m_order; }
96
97 friend constexpr bool operator!=(QPartialOrdering lhs, QPartialOrdering rhs) noexcept
98 { return lhs.m_order != rhs.m_order; }
99
100private:
101 constexpr explicit QPartialOrdering(QtPrivate::Ordering order) noexcept
102 : m_order(static_cast<QtPrivate::CompareUnderlyingType>(order))
103 {}
104 constexpr explicit QPartialOrdering(QtPrivate::Uncomparable order) noexcept
105 : m_order(static_cast<QtPrivate::CompareUnderlyingType>(order))
106 {}
107
108 // instead of the exposition only is_ordered member in [cmp.partialord],
109 // use a private function
110 constexpr bool isOrdered() noexcept
112
114};
115
120
122
123#endif // QCOMPARE_H
friend constexpr bool operator==(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
Definition qcompare.h:44
friend constexpr bool operator<(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
Definition qcompare.h:52
friend constexpr bool operator==(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept
Definition qcompare.h:69
friend constexpr bool operator>(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
Definition qcompare.h:60
static const QPartialOrdering Less
Definition qcompare.h:39
friend constexpr bool operator>=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept
Definition qcompare.h:89
friend constexpr bool operator==(QPartialOrdering lhs, QPartialOrdering rhs) noexcept
Definition qcompare.h:94
friend constexpr bool operator!=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept
Definition qcompare.h:73
friend constexpr bool operator<=(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
Definition qcompare.h:56
friend constexpr bool operator!=(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
Definition qcompare.h:48
friend constexpr bool operator!=(QPartialOrdering lhs, QPartialOrdering rhs) noexcept
Definition qcompare.h:97
static const QPartialOrdering Greater
Definition qcompare.h:41
friend constexpr bool operator<=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept
Definition qcompare.h:81
static const QPartialOrdering Equivalent
Definition qcompare.h:40
static const QPartialOrdering Unordered
Definition qcompare.h:42
friend constexpr bool operator>=(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
Definition qcompare.h:64
Combined button and popup list for selecting options.
\macro QT_NAMESPACE
qint8 CompareUnderlyingType
Definition qcompare.h:17
GLfixed GLfixed GLint GLint order
QT_BEGIN_NAMESPACE typedef signed char qint8
Definition qtypes.h:40