QtBase  v6.3.1
qcompare.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QCOMPARE_H
41 #define QCOMPARE_H
42 
43 #if 0
44 #pragma qt_class(QtCompare)
45 #endif
46 
47 #include <QtCore/qglobal.h>
48 #include <QtCore/qcompare_impl.h>
49 
51 
52 namespace QtPrivate {
54 
55 // [cmp.categories.pre] / 1
57 {
58  Equal = 0,
59  Equivalent = Equal,
60  Less = -1,
61  Greater = 1
62 };
63 
65 {
66  Unordered = -127
67 };
68 
69 } // namespace QtPrivate
70 
71 // [cmp.partialord]
73 {
74 public:
75  static const QPartialOrdering Less;
77  static const QPartialOrdering Greater;
79 
81  { return p.isOrdered() && p.m_order == 0; }
83  { return p.isOrdered() && p.m_order != 0; }
85  { return p.isOrdered() && p.m_order < 0; }
87  { return p.isOrdered() && p.m_order <= 0; }
89  { return p.isOrdered() && p.m_order > 0; }
91  { return p.isOrdered() && p.m_order >= 0; }
92 
94  { return p.isOrdered() && 0 == p.m_order; }
96  { return p.isOrdered() && 0 != p.m_order; }
98  { return p.isOrdered() && 0 < p.m_order; }
100  { return p.isOrdered() && 0 <= p.m_order; }
102  { return p.isOrdered() && 0 > p.m_order; }
104  { return p.isOrdered() && 0 >= p.m_order; }
105 
106  friend constexpr bool operator==(QPartialOrdering p1, QPartialOrdering p2) noexcept
107  { return p1.m_order == p2.m_order; }
108  friend constexpr bool operator!=(QPartialOrdering p1, QPartialOrdering p2) noexcept
109  { return p1.m_order != p2.m_order; }
110 
111 private:
112  constexpr explicit QPartialOrdering(QtPrivate::Ordering order) noexcept
113  : m_order(static_cast<QtPrivate::CompareUnderlyingType>(order))
114  {}
115  constexpr explicit QPartialOrdering(QtPrivate::Uncomparable order) noexcept
116  : m_order(static_cast<QtPrivate::CompareUnderlyingType>(order))
117  {}
118 
119  // instead of the exposition only is_ordered member in [cmp.partialord],
120  // use a private function
121  constexpr bool isOrdered() noexcept
122  { return m_order != static_cast<QtPrivate::CompareUnderlyingType>(QtPrivate::Uncomparable::Unordered); }
123 
125 };
126 
131 
133 
134 #endif // QCOMPARE_H
constexpr friend bool operator>(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
Definition: qcompare.h:88
constexpr friend bool operator<(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
Definition: qcompare.h:84
constexpr friend bool operator!=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
Definition: qcompare.h:95
constexpr friend bool operator>=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
Definition: qcompare.h:103
constexpr friend bool operator==(QPartialOrdering p1, QPartialOrdering p2) noexcept
Definition: qcompare.h:106
constexpr friend bool operator<=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
Definition: qcompare.h:99
constexpr friend bool operator!=(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
Definition: qcompare.h:82
static const QPartialOrdering Less
Definition: qcompare.h:75
constexpr friend bool operator>=(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
Definition: qcompare.h:90
constexpr friend bool operator==(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
Definition: qcompare.h:80
static const QPartialOrdering Greater
Definition: qcompare.h:77
constexpr friend bool operator<=(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
Definition: qcompare.h:86
constexpr friend bool operator==(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
Definition: qcompare.h:93
constexpr friend bool operator!=(QPartialOrdering p1, QPartialOrdering p2) noexcept
Definition: qcompare.h:108
static const QPartialOrdering Equivalent
Definition: qcompare.h:76
static const QPartialOrdering Unordered
Definition: qcompare.h:78
QPixmap p2
QPixmap p1
[0]
Uncomparable
Definition: qcompare.h:65
qint8 CompareUnderlyingType
Definition: qcompare.h:53
QT_BEGIN_NAMESPACE typedef signed char qint8
Definition: qglobal.h:283
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
GLfixed GLfixed GLint GLint order
Definition: qopenglext.h:5206