10#pragma qt_class(QtCompare)
13#include <QtCore/qglobal.h>
14#include <QtCore/qcompare_impl.h>
15#include <QtCore/qstdlibdetection.h>
17#ifdef __cpp_lib_bit_cast
20#ifdef __cpp_lib_three_way_comparison
51 #if defined(Q_STL_LIBCPP)
53 #elif defined(Q_STL_LIBSTDCPP) && QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
56 #elif defined(Q_STL_LIBSTDCPP)
58 #elif defined(Q_STL_MSSTL)
60 #elif defined(Q_STL_DINKUMWARE) ||
61 defined(Q_STL_ROGUEWAVE) ||
62 defined(Q_STL_STLPORT) ||
66 # ifdef __cpp_lib_three_way_comparison
67 # error Please report the numeric value of std::partial_ordering::unordered in your STL in a bug report.
70 # error Please handle any newly-added Q_STL_ checks in the above ifdef-ery.
81#if defined(__cpp_lib_bit_cast) && defined(__cpp_lib_three_way_comparison)
95 return is_lt(o) ? O::greater :
105QT_WARNING_DISABLE_MSVC(4702)
108QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
109QT_WARNING_DISABLE_CLANG(
"-Wzero-as-null-pointer-constant")
126 {
return lhs.isOrdered() && lhs.m_order == 0; }
130 {
return !lhs.isOrdered() || lhs.m_order != 0; }
134 {
return lhs.isOrdered() && lhs.m_order < 0; }
138 {
return lhs.isOrdered() && lhs.m_order <= 0; }
142 {
return lhs.isOrdered() && lhs.m_order > 0; }
146 {
return lhs.isOrdered() && lhs.m_order >= 0; }
151 {
return rhs.isOrdered() && 0 == rhs.m_order; }
155 {
return !rhs.isOrdered() || 0 != rhs.m_order; }
159 {
return rhs.isOrdered() && 0 < rhs.m_order; }
163 {
return rhs.isOrdered() && 0 <= rhs.m_order; }
167 {
return rhs.isOrdered() && 0 > rhs.m_order; }
171 {
return rhs.isOrdered() && 0 >= rhs.m_order; }
174#ifdef __cpp_lib_three_way_comparison
186 {
return lhs.m_order == rhs.m_order; }
189 {
return lhs.m_order != rhs.m_order; }
191#ifdef __cpp_lib_three_way_comparison
195#ifdef __cpp_lib_bit_cast
219#ifdef __cpp_lib_bit_cast
280 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
283 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
295 constexpr bool isOrdered()
const noexcept
296 {
return m_order !=
static_cast<QtPrivate::CompareUnderlyingType>(QtPrivate::Uncomparable::Unordered); }
298 QtPrivate::CompareUnderlyingType m_order;
318 {
return lhs.m_order == 0; }
322 {
return lhs.m_order != 0; }
326 {
return lhs.m_order < 0; }
330 {
return lhs.m_order <= 0; }
334 {
return lhs.m_order > 0; }
338 {
return lhs.m_order >= 0; }
343 {
return 0 == rhs.m_order; }
347 {
return 0 != rhs.m_order; }
351 {
return 0 < rhs.m_order; }
355 {
return 0 <= rhs.m_order; }
359 {
return 0 > rhs.m_order; }
363 {
return 0 >= rhs.m_order; }
366#ifdef __cpp_lib_three_way_comparison
378 {
return lhs.m_order == rhs.m_order; }
381 {
return lhs.m_order != rhs.m_order; }
384 {
return static_cast<partial_ordering>(lhs) == rhs; }
387 {
return static_cast<partial_ordering>(lhs) != rhs; }
390 {
return lhs ==
static_cast<partial_ordering>(rhs); }
393 {
return lhs !=
static_cast<partial_ordering>(rhs); }
395#ifdef __cpp_lib_three_way_comparison
399#ifdef __cpp_lib_bit_cast
416#ifdef __cpp_lib_bit_cast
470 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
480 QtPrivate::CompareUnderlyingType m_order;
503 {
return lhs.m_order == 0; }
507 {
return lhs.m_order != 0; }
511 {
return lhs.m_order < 0; }
515 {
return lhs.m_order <= 0; }
519 {
return lhs.m_order > 0; }
523 {
return lhs.m_order >= 0; }
528 {
return 0 == rhs.m_order; }
532 {
return 0 != rhs.m_order; }
536 {
return 0 < rhs.m_order; }
540 {
return 0 <= rhs.m_order; }
544 {
return 0 > rhs.m_order; }
548 {
return 0 >= rhs.m_order; }
551#ifdef __cpp_lib_three_way_comparison
563 {
return lhs.m_order == rhs.m_order; }
566 {
return lhs.m_order != rhs.m_order; }
569 {
return static_cast<partial_ordering>(lhs) == rhs; }
572 {
return static_cast<partial_ordering>(lhs) == rhs; }
575 {
return lhs ==
static_cast<partial_ordering>(rhs); }
578 {
return lhs !=
static_cast<partial_ordering>(rhs); }
581 {
return static_cast<weak_ordering>(lhs) == rhs; }
584 {
return static_cast<weak_ordering>(lhs) == rhs; }
587 {
return lhs ==
static_cast<weak_ordering>(rhs); }
590 {
return lhs !=
static_cast<weak_ordering>(rhs); }
592#ifdef __cpp_lib_three_way_comparison
596#ifdef __cpp_lib_bit_cast
613#ifdef __cpp_lib_bit_cast
666 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
676 QtPrivate::CompareUnderlyingType m_order;
699QT_BEGIN_INCLUDE_NAMESPACE
703#include <QtCore/qcomparehelpers.h>
705QT_END_INCLUDE_NAMESPACE
709template <
typename LeftType,
typename RightType>
710auto qCompareThreeWay(
const LeftType &lhs,
const RightType &rhs);
714template <
typename LT,
typename RT,
717 QtOrderingPrivate::CompareThreeWayTester::HasCompareThreeWay<LT, RT>,
718 QtOrderingPrivate::CompareThreeWayTester::HasCompareThreeWay<RT, LT>>,
720auto qCompareThreeWay(
const LT &lhs,
const RT &rhs)
721 noexcept(QtOrderingPrivate::CompareThreeWayTester::compareThreeWayNoexcept<LT, RT>())
723 using Qt::compareThreeWay;
724 if constexpr (QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay_v<LT, RT>) {
725 return compareThreeWay(lhs, rhs);
727 const auto retval = compareThreeWay(rhs, lhs);
728 return QtOrderingPrivate::reversed(retval);
761 {
return lhs.isOrdered() && lhs.m_order == 0; }
765 {
return !lhs.isOrdered() || lhs.m_order != 0; }
769 {
return lhs.isOrdered() && lhs.m_order < 0; }
773 {
return lhs.isOrdered() && lhs.m_order <= 0; }
777 {
return lhs.isOrdered() && lhs.m_order > 0; }
781 {
return lhs.isOrdered() && lhs.m_order >= 0; }
786 {
return rhs.isOrdered() && 0 == rhs.m_order; }
790 {
return !rhs.isOrdered() || 0 != rhs.m_order; }
794 {
return rhs.isOrdered() && 0 < rhs.m_order; }
798 {
return rhs.isOrdered() && 0 <= rhs.m_order; }
802 {
return rhs.isOrdered() && 0 > rhs.m_order; }
806 {
return rhs.isOrdered() && 0 >= rhs.m_order; }
809#ifdef __cpp_lib_three_way_comparison
821 {
return lhs.m_order == rhs.m_order; }
824 {
return lhs.m_order != rhs.m_order; }
855#if !defined(Q_CC_GNU_ONLY) || (Q_CC_GNU >= 900
)
874#ifdef __cpp_lib_three_way_comparison
913 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
916 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
921 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
933 constexpr bool isOrdered()
const noexcept
\variable Qt::partial_ordering::less
friend constexpr bool operator==(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
static const QPartialOrdering unordered
friend constexpr bool operator==(QPartialOrdering lhs, Qt::partial_ordering rhs) noexcept
static const QPartialOrdering greater
friend constexpr bool operator<(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept
friend constexpr bool operator<(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
static const QPartialOrdering less
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
static const QPartialOrdering Less
friend constexpr bool operator>=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept
friend constexpr bool operator==(QPartialOrdering lhs, QPartialOrdering rhs) noexcept
Return true if lhs and rhs represent the same result; otherwise, returns false.
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 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 Greater
friend constexpr bool operator<=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept
static const QPartialOrdering Equivalent
static const QPartialOrdering Unordered
friend constexpr bool operator>=(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
\variable Qt::weak_ordering::less
friend constexpr bool is_eq(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 operator>(QtPrivate::CompareAgainstLiteralZero, partial_ordering rhs) noexcept
friend constexpr bool is_lt(partial_ordering o) noexcept
friend constexpr bool operator==(QtPrivate::CompareAgainstLiteralZero, partial_ordering rhs) noexcept
friend constexpr bool operator<=(partial_ordering lhs, QtPrivate::CompareAgainstLiteralZero) 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 is_lteq(partial_ordering o) noexcept
friend constexpr bool operator!=(partial_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator<(partial_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator<(QtPrivate::CompareAgainstLiteralZero, partial_ordering rhs) noexcept
static const partial_ordering unordered
friend constexpr bool operator>=(partial_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool is_gt(partial_ordering o) noexcept
friend constexpr bool is_gteq(partial_ordering o) noexcept
static const partial_ordering greater
friend constexpr bool operator!=(partial_ordering lhs, partial_ordering rhs) noexcept
Return true if lhs and rhs represent different results; otherwise, returns true.
static const partial_ordering less
friend constexpr bool operator==(partial_ordering lhs, partial_ordering rhs) noexcept
Return true if lhs and rhs represent the same result; otherwise, returns false.
friend constexpr bool is_neq(partial_ordering o) noexcept
\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
friend constexpr bool operator!=(strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator<(strong_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool operator<(QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) noexcept
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 is_eq(strong_ordering o) noexcept
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>=(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 operator>(QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) noexcept
friend constexpr bool is_lt(strong_ordering o) noexcept
friend constexpr bool operator<=(QtPrivate::CompareAgainstLiteralZero, strong_ordering rhs) 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.
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==(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 operator!=(weak_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
static const weak_ordering less
friend constexpr bool operator<=(weak_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool is_neq(weak_ordering o) noexcept
friend constexpr bool operator<(weak_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool is_gteq(weak_ordering o) noexcept
friend constexpr bool is_gt(weak_ordering o) 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 is_lteq(weak_ordering o) noexcept
friend constexpr bool operator>(QtPrivate::CompareAgainstLiteralZero, weak_ordering rhs) noexcept
friend constexpr bool operator==(weak_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept
friend constexpr bool is_lt(weak_ordering o) noexcept
friend constexpr bool operator!=(QtPrivate::CompareAgainstLiteralZero, weak_ordering rhs) noexcept
friend constexpr bool is_eq(weak_ordering o) noexcept
friend constexpr bool operator>=(weak_ordering lhs, QtPrivate::CompareAgainstLiteralZero) 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>=(QtPrivate::CompareAgainstLiteralZero, weak_ordering rhs) noexcept
static const weak_ordering greater
friend constexpr bool operator>(weak_ordering lhs, QtPrivate::CompareAgainstLiteralZero) 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 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 auto toUnderlying(O o) noexcept
constexpr auto toUnderlying< Qt::weak_ordering >(Qt::weak_ordering o) noexcept
constexpr auto toUnderlying< Qt::strong_ordering >(Qt::strong_ordering o) noexcept
constexpr auto toUnderlying< Qt::partial_ordering >(Qt::partial_ordering o) noexcept
constexpr CompareUnderlyingType LegacyUncomparableValue