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
172#ifdef __cpp_lib_bit_cast
230 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
233 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
238 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
250 constexpr bool isOrdered()
const noexcept
273 {
return lhs.m_order == 0; }
277 {
return lhs.m_order != 0; }
281 {
return lhs.m_order < 0; }
285 {
return lhs.m_order <= 0; }
289 {
return lhs.m_order > 0; }
293 {
return lhs.m_order >= 0; }
298 {
return 0 == rhs.m_order; }
302 {
return 0 != rhs.m_order; }
306 {
return 0 < rhs.m_order; }
310 {
return 0 <= rhs.m_order; }
314 {
return 0 > rhs.m_order; }
318 {
return 0 >= rhs.m_order; }
321#ifdef __cpp_lib_three_way_comparison
333 {
return lhs.m_order == rhs.m_order; }
336 {
return lhs.m_order != rhs.m_order; }
339 {
return static_cast<partial_ordering>(lhs) == rhs; }
342 {
return static_cast<partial_ordering>(lhs) != rhs; }
345 {
return lhs ==
static_cast<partial_ordering>(rhs); }
348 {
return lhs !=
static_cast<partial_ordering>(rhs); }
350#ifdef __cpp_lib_three_way_comparison
364#ifdef __cpp_lib_bit_cast
419 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
424 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
457 {
return lhs.m_order == 0; }
461 {
return lhs.m_order != 0; }
465 {
return lhs.m_order < 0; }
469 {
return lhs.m_order <= 0; }
473 {
return lhs.m_order > 0; }
477 {
return lhs.m_order >= 0; }
482 {
return 0 == rhs.m_order; }
486 {
return 0 != rhs.m_order; }
490 {
return 0 < rhs.m_order; }
494 {
return 0 <= rhs.m_order; }
498 {
return 0 > rhs.m_order; }
502 {
return 0 >= rhs.m_order; }
505#ifdef __cpp_lib_three_way_comparison
517 {
return lhs.m_order == rhs.m_order; }
520 {
return lhs.m_order != rhs.m_order; }
523 {
return static_cast<partial_ordering>(lhs) == rhs; }
526 {
return static_cast<partial_ordering>(lhs) == rhs; }
529 {
return lhs ==
static_cast<partial_ordering>(rhs); }
532 {
return lhs !=
static_cast<partial_ordering>(rhs); }
535 {
return static_cast<weak_ordering>(lhs) == rhs; }
538 {
return static_cast<weak_ordering>(lhs) == rhs; }
541 {
return lhs ==
static_cast<weak_ordering>(rhs); }
544 {
return lhs !=
static_cast<weak_ordering>(rhs); }
546#ifdef __cpp_lib_three_way_comparison
562#ifdef __cpp_lib_bit_cast
615 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
620 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
640QT_BEGIN_INCLUDE_NAMESPACE
644#include <QtCore/qcomparehelpers.h>
646QT_END_INCLUDE_NAMESPACE
650template <
typename LeftType,
typename RightType>
651auto qCompareThreeWay(
const LeftType &lhs,
const RightType &rhs);
655template <
typename LT,
typename RT,
658 QtOrderingPrivate::CompareThreeWayTester::HasCompareThreeWay<LT, RT>,
659 QtOrderingPrivate::CompareThreeWayTester::HasCompareThreeWay<RT, LT>>,
661auto qCompareThreeWay(
const LT &lhs,
const RT &rhs)
662 noexcept(QtOrderingPrivate::CompareThreeWayTester::compareThreeWayNoexcept<LT, RT>())
664 using Qt::compareThreeWay;
665 if constexpr (QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay_v<LT, RT>) {
666 return compareThreeWay(lhs, rhs);
668 const auto retval = compareThreeWay(rhs, lhs);
669 return QtOrderingPrivate::reversed(retval);
702 {
return lhs.isOrdered() && lhs.m_order == 0; }
706 {
return !lhs.isOrdered() || lhs.m_order != 0; }
710 {
return lhs.isOrdered() && lhs.m_order < 0; }
714 {
return lhs.isOrdered() && lhs.m_order <= 0; }
718 {
return lhs.isOrdered() && lhs.m_order > 0; }
722 {
return lhs.isOrdered() && lhs.m_order >= 0; }
727 {
return rhs.isOrdered() && 0 == rhs.m_order; }
731 {
return !rhs.isOrdered() || 0 != rhs.m_order; }
735 {
return rhs.isOrdered() && 0 < rhs.m_order; }
739 {
return rhs.isOrdered() && 0 <= rhs.m_order; }
743 {
return rhs.isOrdered() && 0 > rhs.m_order; }
747 {
return rhs.isOrdered() && 0 >= rhs.m_order; }
750#ifdef __cpp_lib_three_way_comparison
762 {
return lhs.m_order == rhs.m_order; }
765 {
return lhs.m_order != rhs.m_order; }
796#if !defined(Q_CC_GNU_ONLY) || (Q_CC_GNU >= 900
)
815#ifdef __cpp_lib_three_way_comparison
863 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
866 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
871 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
883 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
Combined button and popup list for selecting options.
constexpr O reversed(O o) noexcept
constexpr CompareUnderlyingType LegacyUncomparableValue