9#pragma qt_class(QtCompare)
12#include <QtCore/qglobal.h>
13#include <QtCore/qcompare_impl.h>
14#include <QtCore/qstdlibdetection.h>
16#ifdef __cpp_lib_bit_cast
19#ifdef __cpp_lib_three_way_comparison
41 #if defined(Q_STL_LIBCPP)
43 #elif defined(Q_STL_LIBSTDCPP)
45 #elif defined(Q_STL_MSSTL)
47 #elif defined(Q_STL_DINKUMWARE) ||
48 defined(Q_STL_ROGUEWAVE) ||
49 defined(Q_STL_STLPORT) ||
53 # ifdef __cpp_lib_three_way_comparison
54 # error Please report the numeric value of std::partial_ordering::unordered in your STL in a bug report.
57 # error Please handle any newly-added Q_STL_ checks in the above ifdef-ery.
69 return is_lt(o) ? O::greater :
91 {
return lhs.isOrdered() && lhs.m_order == 0; }
95 {
return !lhs.isOrdered() || lhs.m_order != 0; }
99 {
return lhs.isOrdered() && lhs.m_order < 0; }
103 {
return lhs.isOrdered() && lhs.m_order <= 0; }
107 {
return lhs.isOrdered() && lhs.m_order > 0; }
111 {
return lhs.isOrdered() && lhs.m_order >= 0; }
116 {
return rhs.isOrdered() && 0 == rhs.m_order; }
120 {
return !rhs.isOrdered() || 0 != rhs.m_order; }
124 {
return rhs.isOrdered() && 0 < rhs.m_order; }
128 {
return rhs.isOrdered() && 0 <= rhs.m_order; }
132 {
return rhs.isOrdered() && 0 > rhs.m_order; }
136 {
return rhs.isOrdered() && 0 >= rhs.m_order; }
139#ifdef __cpp_lib_three_way_comparison
151 {
return lhs.m_order == rhs.m_order; }
154 {
return lhs.m_order != rhs.m_order; }
156#ifdef __cpp_lib_three_way_comparison
171#ifdef __cpp_lib_bit_cast
229 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
232 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
237 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
249 constexpr bool isOrdered()
const noexcept
272 {
return lhs.m_order == 0; }
276 {
return lhs.m_order != 0; }
280 {
return lhs.m_order < 0; }
284 {
return lhs.m_order <= 0; }
288 {
return lhs.m_order > 0; }
292 {
return lhs.m_order >= 0; }
297 {
return 0 == rhs.m_order; }
301 {
return 0 != rhs.m_order; }
305 {
return 0 < rhs.m_order; }
309 {
return 0 <= rhs.m_order; }
313 {
return 0 > rhs.m_order; }
317 {
return 0 >= rhs.m_order; }
320#ifdef __cpp_lib_three_way_comparison
332 {
return lhs.m_order == rhs.m_order; }
335 {
return lhs.m_order != rhs.m_order; }
338 {
return static_cast<partial_ordering>(lhs) == rhs; }
341 {
return static_cast<partial_ordering>(lhs) != rhs; }
344 {
return lhs ==
static_cast<partial_ordering>(rhs); }
347 {
return lhs !=
static_cast<partial_ordering>(rhs); }
349#ifdef __cpp_lib_three_way_comparison
362#ifdef __cpp_lib_bit_cast
417 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
422 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
455 {
return lhs.m_order == 0; }
459 {
return lhs.m_order != 0; }
463 {
return lhs.m_order < 0; }
467 {
return lhs.m_order <= 0; }
471 {
return lhs.m_order > 0; }
475 {
return lhs.m_order >= 0; }
480 {
return 0 == rhs.m_order; }
484 {
return 0 != rhs.m_order; }
488 {
return 0 < rhs.m_order; }
492 {
return 0 <= rhs.m_order; }
496 {
return 0 > rhs.m_order; }
500 {
return 0 >= rhs.m_order; }
503#ifdef __cpp_lib_three_way_comparison
515 {
return lhs.m_order == rhs.m_order; }
518 {
return lhs.m_order != rhs.m_order; }
521 {
return static_cast<partial_ordering>(lhs) == rhs; }
524 {
return static_cast<partial_ordering>(lhs) == rhs; }
527 {
return lhs ==
static_cast<partial_ordering>(rhs); }
530 {
return lhs !=
static_cast<partial_ordering>(rhs); }
533 {
return static_cast<weak_ordering>(lhs) == rhs; }
536 {
return static_cast<weak_ordering>(lhs) == rhs; }
539 {
return lhs ==
static_cast<weak_ordering>(rhs); }
542 {
return lhs !=
static_cast<weak_ordering>(rhs); }
544#ifdef __cpp_lib_three_way_comparison
557#ifdef __cpp_lib_bit_cast
610 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
615 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
635QT_BEGIN_INCLUDE_NAMESPACE
639#include <QtCore/qcomparehelpers.h>
641QT_END_INCLUDE_NAMESPACE
645template <
typename LeftType,
typename RightType>
646auto qCompareThreeWay(
const LeftType &lhs,
const RightType &rhs);
650template <
typename LT,
typename RT,
653 QtOrderingPrivate::CompareThreeWayTester::HasCompareThreeWay<LT, RT>,
654 QtOrderingPrivate::CompareThreeWayTester::HasCompareThreeWay<RT, LT>>,
656auto qCompareThreeWay(
const LT &lhs,
const RT &rhs)
657 noexcept(QtOrderingPrivate::CompareThreeWayTester::compareThreeWayNoexcept<LT, RT>())
659 using Qt::compareThreeWay;
660 if constexpr (QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay_v<LT, RT>) {
661 return compareThreeWay(lhs, rhs);
663 const auto retval = compareThreeWay(rhs, lhs);
664 return QtOrderingPrivate::reversed(retval);
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; }
717 {
return lhs.isOrdered() && lhs.m_order >= 0; }
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; }
742 {
return rhs.isOrdered() && 0 >= rhs.m_order; }
745#ifdef __cpp_lib_three_way_comparison
757 {
return lhs.m_order == rhs.m_order; }
760 {
return lhs.m_order != rhs.m_order; }
791#if !defined(Q_CC_GNU_ONLY) || (Q_CC_GNU >= 900
)
810#ifdef __cpp_lib_three_way_comparison
857 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
860 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
865 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
877 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 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==(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 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
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.
\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 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 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 operator!=(strong_ordering lhs, partial_ordering rhs) 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 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 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 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>(QtPrivate::CompareAgainstLiteralZero, weak_ordering rhs) 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, 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
constexpr O reversed(O o) noexcept
constexpr CompareUnderlyingType LegacyUncomparableValue