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
50 #if defined(Q_STL_LIBCPP)
52 #elif defined(Q_STL_LIBSTDCPP) && QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
55 #elif defined(Q_STL_LIBSTDCPP)
57 #elif defined(Q_STL_MSSTL)
59 #elif defined(Q_STL_DINKUMWARE) ||
60 defined(Q_STL_ROGUEWAVE) ||
61 defined(Q_STL_STLPORT) ||
65 # ifdef __cpp_lib_three_way_comparison
66 # error Please report the numeric value of std::partial_ordering::unordered in your STL in a bug report.
69 # error Please handle any newly-added Q_STL_ checks in the above ifdef-ery.
80#if defined(__cpp_lib_bit_cast) && defined(__cpp_lib_three_way_comparison)
94 return is_lt(o) ? O::greater :
104QT_WARNING_DISABLE_MSVC(4702)
107QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
108QT_WARNING_DISABLE_CLANG(
"-Wzero-as-null-pointer-constant")
125 {
return lhs.isOrdered() && lhs.m_order == 0; }
129 {
return !lhs.isOrdered() || lhs.m_order != 0; }
133 {
return lhs.isOrdered() && lhs.m_order < 0; }
137 {
return lhs.isOrdered() && lhs.m_order <= 0; }
141 {
return lhs.isOrdered() && lhs.m_order > 0; }
145 {
return lhs.isOrdered() && lhs.m_order >= 0; }
150 {
return rhs.isOrdered() && 0 == rhs.m_order; }
154 {
return !rhs.isOrdered() || 0 != rhs.m_order; }
158 {
return rhs.isOrdered() && 0 < rhs.m_order; }
162 {
return rhs.isOrdered() && 0 <= rhs.m_order; }
166 {
return rhs.isOrdered() && 0 > rhs.m_order; }
170 {
return rhs.isOrdered() && 0 >= rhs.m_order; }
173#ifdef __cpp_lib_three_way_comparison
185 {
return lhs.m_order == rhs.m_order; }
188 {
return lhs.m_order != rhs.m_order; }
190#ifdef __cpp_lib_three_way_comparison
194#ifdef __cpp_lib_bit_cast
218#ifdef __cpp_lib_bit_cast
279 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
282 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
294 constexpr bool isOrdered()
const noexcept
295 {
return m_order !=
static_cast<QtPrivate::CompareUnderlyingType>(QtPrivate::Uncomparable::Unordered); }
297 QtPrivate::CompareUnderlyingType m_order;
317 {
return lhs.m_order == 0; }
321 {
return lhs.m_order != 0; }
325 {
return lhs.m_order < 0; }
329 {
return lhs.m_order <= 0; }
333 {
return lhs.m_order > 0; }
337 {
return lhs.m_order >= 0; }
342 {
return 0 == rhs.m_order; }
346 {
return 0 != rhs.m_order; }
350 {
return 0 < rhs.m_order; }
354 {
return 0 <= rhs.m_order; }
358 {
return 0 > rhs.m_order; }
362 {
return 0 >= rhs.m_order; }
365#ifdef __cpp_lib_three_way_comparison
377 {
return lhs.m_order == rhs.m_order; }
380 {
return lhs.m_order != rhs.m_order; }
383 {
return static_cast<partial_ordering>(lhs) == rhs; }
386 {
return static_cast<partial_ordering>(lhs) != rhs; }
389 {
return lhs ==
static_cast<partial_ordering>(rhs); }
392 {
return lhs !=
static_cast<partial_ordering>(rhs); }
394#ifdef __cpp_lib_three_way_comparison
398#ifdef __cpp_lib_bit_cast
415#ifdef __cpp_lib_bit_cast
469 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
479 QtPrivate::CompareUnderlyingType m_order;
502 {
return lhs.m_order == 0; }
506 {
return lhs.m_order != 0; }
510 {
return lhs.m_order < 0; }
514 {
return lhs.m_order <= 0; }
518 {
return lhs.m_order > 0; }
522 {
return lhs.m_order >= 0; }
527 {
return 0 == rhs.m_order; }
531 {
return 0 != rhs.m_order; }
535 {
return 0 < rhs.m_order; }
539 {
return 0 <= rhs.m_order; }
543 {
return 0 > rhs.m_order; }
547 {
return 0 >= rhs.m_order; }
550#ifdef __cpp_lib_three_way_comparison
562 {
return lhs.m_order == rhs.m_order; }
565 {
return lhs.m_order != rhs.m_order; }
568 {
return static_cast<partial_ordering>(lhs) == rhs; }
571 {
return static_cast<partial_ordering>(lhs) == rhs; }
574 {
return lhs ==
static_cast<partial_ordering>(rhs); }
577 {
return lhs !=
static_cast<partial_ordering>(rhs); }
580 {
return static_cast<weak_ordering>(lhs) == rhs; }
583 {
return static_cast<weak_ordering>(lhs) == rhs; }
586 {
return lhs ==
static_cast<weak_ordering>(rhs); }
589 {
return lhs !=
static_cast<weak_ordering>(rhs); }
591#ifdef __cpp_lib_three_way_comparison
595#ifdef __cpp_lib_bit_cast
612#ifdef __cpp_lib_bit_cast
665 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
675 QtPrivate::CompareUnderlyingType m_order;
698QT_BEGIN_INCLUDE_NAMESPACE
702#include <QtCore/qcomparehelpers.h>
704QT_END_INCLUDE_NAMESPACE
708template <
typename LeftType,
typename RightType>
709auto qCompareThreeWay(
const LeftType &lhs,
const RightType &rhs);
713template <
typename LT,
typename RT,
716 QtOrderingPrivate::CompareThreeWayTester::HasCompareThreeWay<LT, RT>,
717 QtOrderingPrivate::CompareThreeWayTester::HasCompareThreeWay<RT, LT>>,
719auto qCompareThreeWay(
const LT &lhs,
const RT &rhs)
720 noexcept(QtOrderingPrivate::CompareThreeWayTester::compareThreeWayNoexcept<LT, RT>())
722 using Qt::compareThreeWay;
723 if constexpr (QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay_v<LT, RT>) {
724 return compareThreeWay(lhs, rhs);
726 const auto retval = compareThreeWay(rhs, lhs);
727 return QtOrderingPrivate::reversed(retval);
760 {
return lhs.isOrdered() && lhs.m_order == 0; }
764 {
return !lhs.isOrdered() || lhs.m_order != 0; }
768 {
return lhs.isOrdered() && lhs.m_order < 0; }
772 {
return lhs.isOrdered() && lhs.m_order <= 0; }
776 {
return lhs.isOrdered() && lhs.m_order > 0; }
780 {
return lhs.isOrdered() && lhs.m_order >= 0; }
785 {
return rhs.isOrdered() && 0 == rhs.m_order; }
789 {
return !rhs.isOrdered() || 0 != rhs.m_order; }
793 {
return rhs.isOrdered() && 0 < rhs.m_order; }
797 {
return rhs.isOrdered() && 0 <= rhs.m_order; }
801 {
return rhs.isOrdered() && 0 > rhs.m_order; }
805 {
return rhs.isOrdered() && 0 >= rhs.m_order; }
808#ifdef __cpp_lib_three_way_comparison
820 {
return lhs.m_order == rhs.m_order; }
823 {
return lhs.m_order != rhs.m_order; }
854#if !defined(Q_CC_GNU_ONLY) || (Q_CC_GNU >= 900
)
873#ifdef __cpp_lib_three_way_comparison
912 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
915 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
920 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
932 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