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 :
78 {
return lhs.isOrdered() && lhs.m_order == 0; }
82 {
return lhs.isOrdered() && lhs.m_order != 0; }
86 {
return lhs.isOrdered() && lhs.m_order < 0; }
90 {
return lhs.isOrdered() && lhs.m_order <= 0; }
94 {
return lhs.isOrdered() && lhs.m_order > 0; }
98 {
return lhs.isOrdered() && lhs.m_order >= 0; }
103 {
return rhs.isOrdered() && 0 == rhs.m_order; }
107 {
return rhs.isOrdered() && 0 != rhs.m_order; }
111 {
return rhs.isOrdered() && 0 < rhs.m_order; }
115 {
return rhs.isOrdered() && 0 <= rhs.m_order; }
119 {
return rhs.isOrdered() && 0 > rhs.m_order; }
123 {
return rhs.isOrdered() && 0 >= rhs.m_order; }
126#ifdef __cpp_lib_three_way_comparison
127 friend constexpr std::partial_ordering
131 friend constexpr std::partial_ordering
138 {
return lhs.m_order == rhs.m_order; }
141 {
return lhs.m_order != rhs.m_order; }
143#ifdef __cpp_lib_three_way_comparison
146 if (stdorder == std::partial_ordering::less)
148 else if (stdorder == std::partial_ordering::equivalent)
150 else if (stdorder == std::partial_ordering::greater)
152 else if (stdorder == std::partial_ordering::unordered)
156 constexpr Q_IMPLICIT operator std::partial_ordering() const noexcept
158 static_assert(
sizeof(*this) ==
sizeof(std::partial_ordering));
159#ifdef __cpp_lib_bit_cast
160 return std::bit_cast<std::partial_ordering>(*
this);
164 using R = std::partial_ordering;
171 Q_UNREACHABLE_RETURN(R::unordered);
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!=(partial_ordering lhs, std::partial_ordering rhs)
noexcept
179 {
return static_cast<std::partial_ordering
>(lhs) != rhs; }
181 friend constexpr bool operator==(std::partial_ordering lhs, partial_ordering rhs)
noexcept
182 {
return lhs ==
static_cast<std::partial_ordering
>(rhs); }
184 friend constexpr bool operator!=(std::partial_ordering lhs, partial_ordering rhs)
noexcept
185 {
return lhs !=
static_cast<std::partial_ordering
>(rhs); }
212 constexpr bool isOrdered() const noexcept
235 {
return lhs.m_order == 0; }
239 {
return lhs.m_order != 0; }
243 {
return lhs.m_order < 0; }
247 {
return lhs.m_order <= 0; }
251 {
return lhs.m_order > 0; }
255 {
return lhs.m_order >= 0; }
260 {
return 0 == rhs.m_order; }
264 {
return 0 != rhs.m_order; }
268 {
return 0 < rhs.m_order; }
272 {
return 0 <= rhs.m_order; }
276 {
return 0 > rhs.m_order; }
280 {
return 0 >= rhs.m_order; }
283#ifdef __cpp_lib_three_way_comparison
284 friend constexpr std::weak_ordering
288 friend constexpr std::weak_ordering
295 {
return lhs.m_order == rhs.m_order; }
298 {
return lhs.m_order != rhs.m_order; }
312#ifdef __cpp_lib_three_way_comparison
315 if (stdorder == std::weak_ordering::less)
317 else if (stdorder == std::weak_ordering::equivalent)
319 else if (stdorder == std::weak_ordering::greater)
323 constexpr Q_IMPLICIT operator std::weak_ordering() const noexcept
325 static_assert(
sizeof(*this) ==
sizeof(std::weak_ordering));
326#ifdef __cpp_lib_bit_cast
327 return std::bit_cast<std::weak_ordering>(*
this);
330 using R = std::weak_ordering;
336 Q_UNREACHABLE_RETURN(R::equivalent);
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::weak_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::partial_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!=(weak_ordering lhs, std::strong_ordering rhs)
noexcept
356 {
return static_cast<std::weak_ordering
>(lhs) != 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::weak_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::partial_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); }
373 friend constexpr bool operator!=(std::strong_ordering lhs, weak_ordering rhs)
noexcept
374 {
return lhs !=
static_cast<std::weak_ordering
>(rhs); }
418 {
return lhs.m_order == 0; }
422 {
return lhs.m_order != 0; }
426 {
return lhs.m_order < 0; }
430 {
return lhs.m_order <= 0; }
434 {
return lhs.m_order > 0; }
438 {
return lhs.m_order >= 0; }
443 {
return 0 == rhs.m_order; }
447 {
return 0 != rhs.m_order; }
451 {
return 0 < rhs.m_order; }
455 {
return 0 <= rhs.m_order; }
459 {
return 0 > rhs.m_order; }
463 {
return 0 >= rhs.m_order; }
466#ifdef __cpp_lib_three_way_comparison
467 friend constexpr std::strong_ordering
471 friend constexpr std::strong_ordering
478 {
return lhs.m_order == rhs.m_order; }
481 {
return lhs.m_order != rhs.m_order; }
507#ifdef __cpp_lib_three_way_comparison
510 if (stdorder == std::strong_ordering::less)
512 else if (stdorder == std::strong_ordering::equivalent)
514 else if (stdorder == std::strong_ordering::equal)
516 else if (stdorder == std::strong_ordering::greater)
520 constexpr Q_IMPLICIT operator std::strong_ordering() const noexcept
522 static_assert(
sizeof(*this) ==
sizeof(std::strong_ordering));
523#ifdef __cpp_lib_bit_cast
524 return std::bit_cast<std::strong_ordering>(*
this);
527 using R = std::strong_ordering;
533 Q_UNREACHABLE_RETURN(R::equal);
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::strong_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::partial_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!=(strong_ordering lhs, std::weak_ordering rhs)
noexcept
553 {
return static_cast<std::strong_ordering
>(lhs) != 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::strong_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::partial_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); }
570 friend constexpr bool operator!=(std::weak_ordering lhs, strong_ordering rhs)
noexcept
571 {
return lhs !=
static_cast<std::strong_ordering
>(rhs); }
604#include <QtCore/qcomparehelpers.h>
610namespace CompareThreeWayTester {
616 template <
typename LT,
typename RT,
typename =
void>
619 template <
typename LT,
typename RT>
621 LT, RT, std::void_t<decltype(compareThreeWay(std::declval<LT>(), std::declval<RT>()))>
629 template <
typename LT,
typename RT,
630 std::enable_if_t<hasCompareThreeWay<LT, RT>,
bool> =
true>
632 {
return noexcept(
compareThreeWay(std::declval<LT>(), std::declval<RT>())); }
634 template <
typename LT,
typename RT,
635 std::enable_if_t<!hasCompareThreeWay<LT, RT> && hasCompareThreeWay<RT, LT>,
638 {
return noexcept(
compareThreeWay(std::declval<RT>(), std::declval<LT>())); }
646template <
typename LeftType,
typename RightType>
651template <
typename LT,
typename RT,
652 std::enable_if_t<QtPrivate::CompareThreeWayTester::hasCompareThreeWay<LT, RT>
653 || QtPrivate::CompareThreeWayTester::hasCompareThreeWay<RT, LT>,
656 noexcept(QtPrivate::CompareThreeWayTester::compareThreeWayNoexcept<LT, RT>())
659 if constexpr (QtPrivate::CompareThreeWayTester::hasCompareThreeWay<LT, RT>) {
696 {
return lhs.isOrdered() && lhs.m_order == 0; }
700 {
return lhs.isOrdered() && lhs.m_order != 0; }
704 {
return lhs.isOrdered() && lhs.m_order < 0; }
708 {
return lhs.isOrdered() && lhs.m_order <= 0; }
712 {
return lhs.isOrdered() && lhs.m_order > 0; }
716 {
return lhs.isOrdered() && lhs.m_order >= 0; }
721 {
return rhs.isOrdered() && 0 == rhs.m_order; }
725 {
return rhs.isOrdered() && 0 != rhs.m_order; }
729 {
return rhs.isOrdered() && 0 < rhs.m_order; }
733 {
return rhs.isOrdered() && 0 <= rhs.m_order; }
737 {
return rhs.isOrdered() && 0 > rhs.m_order; }
741 {
return rhs.isOrdered() && 0 >= rhs.m_order; }
744#ifdef __cpp_lib_three_way_comparison
745 friend constexpr std::partial_ordering
749 friend constexpr std::partial_ordering
756 {
return lhs.m_order == rhs.m_order; }
759 {
return lhs.m_order != rhs.m_order; }
790#if !defined(Q_CC_GNU_ONLY) || (Q_CC_GNU >= 900)
809#ifdef __cpp_lib_three_way_comparison
812 if (stdorder == std::partial_ordering::less)
814 else if (stdorder == std::partial_ordering::equivalent)
816 else if (stdorder == std::partial_ordering::greater)
818 else if (stdorder == std::partial_ordering::unordered)
828 constexpr Q_IMPLICIT operator std::partial_ordering() const noexcept
832 using R = std::partial_ordering;
839 Q_UNREACHABLE_RETURN(R::unordered);
843 {
return static_cast<std::partial_ordering
>(lhs) == rhs; }
846 {
return static_cast<std::partial_ordering
>(lhs) != rhs; }
849 {
return lhs ==
static_cast<std::partial_ordering
>(rhs); }
852 {
return lhs !=
static_cast<std::partial_ordering
>(rhs); }
876 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)