9#pragma qt_class(QtCompare)
12#include <QtCore/qglobal.h>
13#include <QtCore/qcompare_impl.h>
15#ifdef __cpp_lib_bit_cast
18#ifdef __cpp_lib_three_way_comparison
39 #if defined(_LIBCPP_VERSION)
41 #elif defined(__GLIBCXX__)
56 return is_lt(
o) ? O::greater :
75 {
return lhs.isOrdered() && lhs.m_order == 0; }
79 {
return lhs.isOrdered() && lhs.m_order != 0; }
83 {
return lhs.isOrdered() && lhs.m_order < 0; }
87 {
return lhs.isOrdered() && lhs.m_order <= 0; }
91 {
return lhs.isOrdered() && lhs.m_order > 0; }
95 {
return lhs.isOrdered() && lhs.m_order >= 0; }
100 {
return rhs.isOrdered() && 0 == rhs.m_order; }
104 {
return rhs.isOrdered() && 0 != rhs.m_order; }
108 {
return rhs.isOrdered() && 0 < rhs.m_order; }
112 {
return rhs.isOrdered() && 0 <= rhs.m_order; }
116 {
return rhs.isOrdered() && 0 > rhs.m_order; }
120 {
return rhs.isOrdered() && 0 >= rhs.m_order; }
123#ifdef __cpp_lib_three_way_comparison
124 friend constexpr std::partial_ordering
128 friend constexpr std::partial_ordering
135 {
return lhs.m_order == rhs.m_order; }
138 {
return lhs.m_order != rhs.m_order; }
140#ifdef __cpp_lib_three_way_comparison
143 if (stdorder == std::partial_ordering::less)
145 else if (stdorder == std::partial_ordering::equivalent)
147 else if (stdorder == std::partial_ordering::greater)
149 else if (stdorder == std::partial_ordering::unordered)
153 constexpr Q_IMPLICIT operator std::partial_ordering() const noexcept
155 static_assert(
sizeof(*this) ==
sizeof(std::partial_ordering));
156#ifdef __cpp_lib_bit_cast
157 return std::bit_cast<std::partial_ordering>(*
this);
161 using R = std::partial_ordering;
168 Q_UNREACHABLE_RETURN(R::unordered);
172 friend constexpr bool operator==(partial_ordering lhs, std::partial_ordering rhs)
noexcept
173 {
return static_cast<std::partial_ordering
>(lhs) == rhs; }
175 friend constexpr bool operator!=(partial_ordering lhs, std::partial_ordering rhs)
noexcept
176 {
return static_cast<std::partial_ordering
>(lhs) != rhs; }
178 friend constexpr bool operator==(std::partial_ordering lhs, partial_ordering rhs)
noexcept
179 {
return lhs ==
static_cast<std::partial_ordering
>(rhs); }
181 friend constexpr bool operator!=(std::partial_ordering lhs, partial_ordering rhs)
noexcept
182 {
return lhs !=
static_cast<std::partial_ordering
>(rhs); }
209 constexpr bool isOrdered() const noexcept
232 {
return lhs.m_order == 0; }
236 {
return lhs.m_order != 0; }
240 {
return lhs.m_order < 0; }
244 {
return lhs.m_order <= 0; }
248 {
return lhs.m_order > 0; }
252 {
return lhs.m_order >= 0; }
257 {
return 0 == rhs.m_order; }
261 {
return 0 != rhs.m_order; }
265 {
return 0 < rhs.m_order; }
269 {
return 0 <= rhs.m_order; }
273 {
return 0 > rhs.m_order; }
277 {
return 0 >= rhs.m_order; }
280#ifdef __cpp_lib_three_way_comparison
281 friend constexpr std::weak_ordering
285 friend constexpr std::weak_ordering
292 {
return lhs.m_order == rhs.m_order; }
295 {
return lhs.m_order != rhs.m_order; }
309#ifdef __cpp_lib_three_way_comparison
312 if (stdorder == std::weak_ordering::less)
314 else if (stdorder == std::weak_ordering::equivalent)
316 else if (stdorder == std::weak_ordering::greater)
320 constexpr Q_IMPLICIT operator std::weak_ordering() const noexcept
322 static_assert(
sizeof(*this) ==
sizeof(std::weak_ordering));
323#ifdef __cpp_lib_bit_cast
324 return std::bit_cast<std::weak_ordering>(*
this);
327 using R = std::weak_ordering;
333 Q_UNREACHABLE_RETURN(R::equivalent);
337 friend constexpr bool operator==(weak_ordering lhs, std::weak_ordering rhs)
noexcept
338 {
return static_cast<std::weak_ordering
>(lhs) == rhs; }
340 friend constexpr bool operator!=(weak_ordering lhs, std::weak_ordering rhs)
noexcept
341 {
return static_cast<std::weak_ordering
>(lhs) != rhs; }
343 friend constexpr bool operator==(weak_ordering lhs, std::partial_ordering rhs)
noexcept
344 {
return static_cast<std::weak_ordering
>(lhs) == rhs; }
346 friend constexpr bool operator!=(weak_ordering lhs, std::partial_ordering rhs)
noexcept
347 {
return static_cast<std::weak_ordering
>(lhs) != rhs; }
349 friend constexpr bool operator==(weak_ordering lhs, std::strong_ordering rhs)
noexcept
350 {
return static_cast<std::weak_ordering
>(lhs) == rhs; }
352 friend constexpr bool operator!=(weak_ordering lhs, std::strong_ordering rhs)
noexcept
353 {
return static_cast<std::weak_ordering
>(lhs) != rhs; }
355 friend constexpr bool operator==(std::weak_ordering lhs, weak_ordering rhs)
noexcept
356 {
return lhs ==
static_cast<std::weak_ordering
>(rhs); }
358 friend constexpr bool operator!=(std::weak_ordering lhs, weak_ordering rhs)
noexcept
359 {
return lhs !=
static_cast<std::weak_ordering
>(rhs); }
361 friend constexpr bool operator==(std::partial_ordering lhs, weak_ordering rhs)
noexcept
362 {
return lhs ==
static_cast<std::weak_ordering
>(rhs); }
364 friend constexpr bool operator!=(std::partial_ordering lhs, weak_ordering rhs)
noexcept
365 {
return lhs !=
static_cast<std::weak_ordering
>(rhs); }
367 friend constexpr bool operator==(std::strong_ordering lhs, weak_ordering rhs)
noexcept
368 {
return lhs ==
static_cast<std::weak_ordering
>(rhs); }
370 friend constexpr bool operator!=(std::strong_ordering lhs, weak_ordering rhs)
noexcept
371 {
return lhs !=
static_cast<std::weak_ordering
>(rhs); }
415 {
return lhs.m_order == 0; }
419 {
return lhs.m_order != 0; }
423 {
return lhs.m_order < 0; }
427 {
return lhs.m_order <= 0; }
431 {
return lhs.m_order > 0; }
435 {
return lhs.m_order >= 0; }
440 {
return 0 == rhs.m_order; }
444 {
return 0 != rhs.m_order; }
448 {
return 0 < rhs.m_order; }
452 {
return 0 <= rhs.m_order; }
456 {
return 0 > rhs.m_order; }
460 {
return 0 >= rhs.m_order; }
463#ifdef __cpp_lib_three_way_comparison
464 friend constexpr std::strong_ordering
468 friend constexpr std::strong_ordering
475 {
return lhs.m_order == rhs.m_order; }
478 {
return lhs.m_order != rhs.m_order; }
504#ifdef __cpp_lib_three_way_comparison
507 if (stdorder == std::strong_ordering::less)
509 else if (stdorder == std::strong_ordering::equivalent)
511 else if (stdorder == std::strong_ordering::equal)
513 else if (stdorder == std::strong_ordering::greater)
517 constexpr Q_IMPLICIT operator std::strong_ordering() const noexcept
519 static_assert(
sizeof(*this) ==
sizeof(std::strong_ordering));
520#ifdef __cpp_lib_bit_cast
521 return std::bit_cast<std::strong_ordering>(*
this);
524 using R = std::strong_ordering;
530 Q_UNREACHABLE_RETURN(R::equal);
534 friend constexpr bool operator==(strong_ordering lhs, std::strong_ordering rhs)
noexcept
535 {
return static_cast<std::strong_ordering
>(lhs) == rhs; }
537 friend constexpr bool operator!=(strong_ordering lhs, std::strong_ordering rhs)
noexcept
538 {
return static_cast<std::strong_ordering
>(lhs) != rhs; }
540 friend constexpr bool operator==(strong_ordering lhs, std::partial_ordering rhs)
noexcept
541 {
return static_cast<std::strong_ordering
>(lhs) == rhs; }
543 friend constexpr bool operator!=(strong_ordering lhs, std::partial_ordering rhs)
noexcept
544 {
return static_cast<std::strong_ordering
>(lhs) != rhs; }
546 friend constexpr bool operator==(strong_ordering lhs, std::weak_ordering rhs)
noexcept
547 {
return static_cast<std::strong_ordering
>(lhs) == rhs; }
549 friend constexpr bool operator!=(strong_ordering lhs, std::weak_ordering rhs)
noexcept
550 {
return static_cast<std::strong_ordering
>(lhs) != rhs; }
552 friend constexpr bool operator==(std::strong_ordering lhs, strong_ordering rhs)
noexcept
553 {
return lhs ==
static_cast<std::strong_ordering
>(rhs); }
555 friend constexpr bool operator!=(std::strong_ordering lhs, strong_ordering rhs)
noexcept
556 {
return lhs !=
static_cast<std::strong_ordering
>(rhs); }
558 friend constexpr bool operator==(std::partial_ordering lhs, strong_ordering rhs)
noexcept
559 {
return lhs ==
static_cast<std::strong_ordering
>(rhs); }
561 friend constexpr bool operator!=(std::partial_ordering lhs, strong_ordering rhs)
noexcept
562 {
return lhs !=
static_cast<std::strong_ordering
>(rhs); }
564 friend constexpr bool operator==(std::weak_ordering lhs, strong_ordering rhs)
noexcept
565 {
return lhs ==
static_cast<std::strong_ordering
>(rhs); }
567 friend constexpr bool operator!=(std::weak_ordering lhs, strong_ordering rhs)
noexcept
568 {
return lhs !=
static_cast<std::strong_ordering
>(rhs); }
601#include <QtCore/qcomparehelpers.h>
607namespace CompareThreeWayTester {
613 template <
typename LT,
typename RT,
typename =
void>
616 template <
typename LT,
typename RT>
618 LT, RT, std::void_t<decltype(compareThreeWay(std::declval<LT>(), std::declval<RT>()))>
626 template <
typename LT,
typename RT,
627 std::enable_if_t<hasCompareThreeWay<LT, RT>,
bool> =
true>
629 {
return noexcept(
compareThreeWay(std::declval<LT>(), std::declval<RT>())); }
631 template <
typename LT,
typename RT,
632 std::enable_if_t<!hasCompareThreeWay<LT, RT> && hasCompareThreeWay<RT, LT>,
635 {
return noexcept(
compareThreeWay(std::declval<RT>(), std::declval<LT>())); }
643template <
typename LeftType,
typename RightType>
648template <
typename LT,
typename RT,
649 std::enable_if_t<QtPrivate::CompareThreeWayTester::hasCompareThreeWay<LT, RT>
650 || QtPrivate::CompareThreeWayTester::hasCompareThreeWay<RT, LT>,
653 noexcept(QtPrivate::CompareThreeWayTester::compareThreeWayNoexcept<LT, RT>())
656 if constexpr (QtPrivate::CompareThreeWayTester::hasCompareThreeWay<LT, RT>) {
693 {
return lhs.isOrdered() && lhs.m_order == 0; }
697 {
return lhs.isOrdered() && lhs.m_order != 0; }
701 {
return lhs.isOrdered() && lhs.m_order < 0; }
705 {
return lhs.isOrdered() && lhs.m_order <= 0; }
709 {
return lhs.isOrdered() && lhs.m_order > 0; }
713 {
return lhs.isOrdered() && lhs.m_order >= 0; }
718 {
return rhs.isOrdered() && 0 == rhs.m_order; }
722 {
return rhs.isOrdered() && 0 != rhs.m_order; }
726 {
return rhs.isOrdered() && 0 < rhs.m_order; }
730 {
return rhs.isOrdered() && 0 <= rhs.m_order; }
734 {
return rhs.isOrdered() && 0 > rhs.m_order; }
738 {
return rhs.isOrdered() && 0 >= rhs.m_order; }
741#ifdef __cpp_lib_three_way_comparison
742 friend constexpr std::partial_ordering
746 friend constexpr std::partial_ordering
753 {
return lhs.m_order == rhs.m_order; }
756 {
return lhs.m_order != rhs.m_order; }
787#if !defined(Q_CC_GNU_ONLY) || (Q_CC_GNU >= 900)
806#ifdef __cpp_lib_three_way_comparison
809 if (stdorder == std::partial_ordering::less)
811 else if (stdorder == std::partial_ordering::equivalent)
813 else if (stdorder == std::partial_ordering::greater)
815 else if (stdorder == std::partial_ordering::unordered)
825 constexpr Q_IMPLICIT operator std::partial_ordering() const noexcept
829 using R = std::partial_ordering;
836 Q_UNREACHABLE_RETURN(R::unordered);
840 {
return static_cast<std::partial_ordering
>(lhs) == rhs; }
843 {
return static_cast<std::partial_ordering
>(lhs) != rhs; }
846 {
return lhs ==
static_cast<std::partial_ordering
>(rhs); }
849 {
return lhs !=
static_cast<std::partial_ordering
>(rhs); }
873 constexpr bool isOrdered() const noexcept
\variable Qt::partial_ordering::less
friend constexpr bool is_gteq(QPartialOrdering o) noexcept
static const QPartialOrdering unordered
friend constexpr bool is_neq(QPartialOrdering o) noexcept
friend constexpr bool operator==(QPartialOrdering lhs, Qt::partial_ordering rhs) noexcept
constexpr Q_IMPLICIT QPartialOrdering(Qt::partial_ordering order) noexcept
static const QPartialOrdering greater
constexpr Q_IMPLICIT QPartialOrdering(Qt::weak_ordering stdorder) noexcept
friend constexpr bool operator<(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
static const QPartialOrdering less
friend constexpr bool is_lteq(QPartialOrdering o) noexcept
friend constexpr bool operator!=(QPartialOrdering lhs, Qt::partial_ordering rhs) noexcept
friend constexpr bool operator==(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept
friend constexpr bool operator==(Qt::partial_ordering lhs, QPartialOrdering rhs) noexcept
friend constexpr bool operator>(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
constexpr Q_IMPLICIT QPartialOrdering(Qt::strong_ordering stdorder) noexcept
static const QPartialOrdering Less
friend constexpr bool operator==(QPartialOrdering lhs, QPartialOrdering rhs) noexcept
Return true if lhs and rhs represent the same result; otherwise, returns false.
friend constexpr bool is_lt(QPartialOrdering o) noexcept
friend constexpr bool operator>=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept
static const QPartialOrdering equivalent
friend constexpr bool operator!=(Qt::partial_ordering lhs, QPartialOrdering rhs) noexcept
friend constexpr bool operator!=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept
friend constexpr bool operator<=(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator!=(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool is_gt(QPartialOrdering o) noexcept
static const QPartialOrdering Greater
friend constexpr bool operator==(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator!=(QPartialOrdering lhs, QPartialOrdering rhs) noexcept
Return true if lhs and rhs represent different results; otherwise, returns true.
friend constexpr bool operator<=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept
static const QPartialOrdering Equivalent
QT_WARNING_PUSH friend constexpr bool is_eq(QPartialOrdering o) noexcept
static const QPartialOrdering Unordered
friend constexpr bool operator>=(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
\variable Qt::weak_ordering::less
friend constexpr bool is_neq(partial_ordering o) noexcept
friend constexpr bool is_lteq(partial_ordering o) noexcept
friend constexpr bool operator>=(QtPrivate::CompareAgainstLiteralZero, partial_ordering rhs) noexcept
friend constexpr bool operator>(partial_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool is_gt(partial_ordering o) noexcept
friend constexpr bool operator==(QtPrivate::CompareAgainstLiteralZero, partial_ordering rhs) noexcept
friend constexpr bool operator<=(partial_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool is_gteq(partial_ordering o) noexcept
static const partial_ordering equivalent
friend constexpr bool operator<=(QtPrivate::CompareAgainstLiteralZero, partial_ordering rhs) noexcept
friend constexpr bool operator==(partial_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator!=(QtPrivate::CompareAgainstLiteralZero, partial_ordering rhs) noexcept
friend constexpr bool operator!=(partial_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator!=(partial_ordering lhs, partial_ordering rhs) noexcept
Return true if lhs and rhs represent different results; otherwise, returns true.
friend constexpr bool operator<(partial_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool is_lt(partial_ordering o) noexcept
static const partial_ordering unordered
friend constexpr bool operator>=(partial_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
QT_WARNING_PUSH friend constexpr bool is_eq(partial_ordering o) noexcept
friend constexpr bool operator==(partial_ordering lhs, partial_ordering rhs) noexcept
Return true if lhs and rhs represent the same result; otherwise, returns false.
static const partial_ordering greater
static const partial_ordering less
\inmodule QtCore \title Classes and helpers for defining comparison operators \keyword qtcompare
friend constexpr bool operator<=(strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool is_gt(strong_ordering o) noexcept
QT_WARNING_PUSH friend constexpr bool is_eq(strong_ordering o) noexcept
friend constexpr bool operator!=(strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator<(strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator==(strong_ordering lhs, strong_ordering rhs) noexcept
Returns true if lhs and rhs represent the same result; otherwise, returns false.
static const strong_ordering greater
friend constexpr bool operator==(strong_ordering lhs, partial_ordering rhs) noexcept
friend constexpr bool operator>(strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator!=(weak_ordering lhs, strong_ordering rhs) noexcept
friend constexpr bool operator!=(partial_ordering lhs, strong_ordering rhs) noexcept
static const strong_ordering equal
friend constexpr bool operator!=(QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) noexcept
friend constexpr bool operator==(QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) noexcept
friend constexpr bool operator==(strong_ordering lhs, weak_ordering rhs) noexcept
friend constexpr bool operator!=(strong_ordering lhs, strong_ordering rhs) noexcept
Returns true if lhs and rhs represent different results; otherwise, returns true.
friend constexpr bool operator>=(QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) noexcept
static const strong_ordering less
friend constexpr bool operator!=(strong_ordering lhs, weak_ordering rhs) noexcept
friend constexpr bool is_neq(strong_ordering o) noexcept
friend constexpr bool operator!=(strong_ordering lhs, partial_ordering rhs) noexcept
friend constexpr bool is_lteq(strong_ordering o) noexcept
friend constexpr bool operator==(strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
static const strong_ordering equivalent
friend constexpr bool is_lt(strong_ordering o) noexcept
friend constexpr bool operator<=(QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) noexcept
friend constexpr bool operator==(weak_ordering lhs, strong_ordering rhs) noexcept
friend constexpr bool operator==(partial_ordering lhs, strong_ordering rhs) noexcept
friend constexpr bool is_gteq(strong_ordering o) noexcept
friend constexpr bool operator>=(strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
\variable Qt::strong_ordering::less
friend constexpr bool is_lteq(weak_ordering o) noexcept
friend constexpr bool operator==(weak_ordering lhs, weak_ordering rhs) noexcept
Return true if lhs and rhs represent the same result; otherwise, returns false.
friend constexpr bool operator!=(weak_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
QT_WARNING_PUSH friend constexpr bool is_eq(weak_ordering o) noexcept
static const weak_ordering less
friend constexpr bool operator<=(weak_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator<(weak_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator==(weak_ordering lhs, partial_ordering rhs) noexcept
friend constexpr bool is_gteq(weak_ordering o) noexcept
friend constexpr bool is_lt(weak_ordering o) noexcept
friend constexpr bool operator==(weak_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator!=(QtPrivate::CompareAgainstLiteralZero, weak_ordering rhs) noexcept
friend constexpr bool operator!=(weak_ordering lhs, weak_ordering rhs) noexcept
Return true if lhs and rhs represent different results; otherwise, returns true.
friend constexpr bool is_gt(weak_ordering o) noexcept
friend constexpr bool operator>=(weak_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator>=(QtPrivate::CompareAgainstLiteralZero, weak_ordering rhs) noexcept
friend constexpr bool is_neq(weak_ordering o) noexcept
static const weak_ordering greater
friend constexpr bool operator>(weak_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator!=(weak_ordering lhs, partial_ordering rhs) noexcept
friend constexpr bool operator<=(QtPrivate::CompareAgainstLiteralZero, weak_ordering rhs) noexcept
friend constexpr bool operator!=(partial_ordering lhs, weak_ordering rhs) noexcept
friend constexpr bool operator==(partial_ordering lhs, weak_ordering rhs) noexcept
static const weak_ordering equivalent
friend constexpr bool operator==(QtPrivate::CompareAgainstLiteralZero, weak_ordering rhs) noexcept
Combined button and popup list for selecting options.
constexpr O reversed(O o) noexcept
constexpr bool compareThreeWayNoexcept() noexcept
constexpr bool hasCompareThreeWay
qint8 CompareUnderlyingType
constexpr Qt::strong_ordering compareThreeWay(LeftInt lhs, RightInt rhs) noexcept
auto qCompareThreeWay(const LT &lhs, const RT &rhs) noexcept(QtPrivate::CompareThreeWayTester::compareThreeWayNoexcept< LT, RT >())
#define QT_WARNING_DISABLE_GCC(text)
GLfixed GLfixed GLint GLint order
#define QT_BEGIN_INCLUDE_NAMESPACE
#define QT_END_INCLUDE_NAMESPACE
QT_BEGIN_NAMESPACE constexpr std::underlying_type_t< Enum > qToUnderlying(Enum e) noexcept
QT_BEGIN_NAMESPACE typedef signed char qint8
Qt::weak_ordering compareThreeWay(const QUrl &lhs, const QUrl &rhs)