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__)
43 #elif defined(_MSVC_STL_VERSION)
45 #elif defined(Q_CC_GHS)
49 #elif defined(Q_OS_VXWORKS)
53 # error "Unsupported C++ Standard Library implementation. Please submit a bug report."
65 return is_lt(o) ? O::greater :
87 {
return lhs.isOrdered() && lhs.m_order == 0; }
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; }
112 {
return rhs.isOrdered() && 0 == rhs.m_order; }
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; }
135#ifdef __cpp_lib_three_way_comparison
147 {
return lhs.m_order == rhs.m_order; }
150 {
return lhs.m_order != rhs.m_order; }
152#ifdef __cpp_lib_three_way_comparison
168#ifdef __cpp_lib_bit_cast
226 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
229 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
234 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
245 constexpr bool isOrdered()
const noexcept
268 {
return lhs.m_order == 0; }
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; }
293 {
return 0 == rhs.m_order; }
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; }
316#ifdef __cpp_lib_three_way_comparison
328 {
return lhs.m_order == rhs.m_order; }
331 {
return lhs.m_order != rhs.m_order; }
334 {
return static_cast<partial_ordering>(lhs) == rhs; }
337 {
return static_cast<partial_ordering>(lhs) != rhs; }
340 {
return lhs ==
static_cast<partial_ordering>(rhs); }
343 {
return lhs !=
static_cast<partial_ordering>(rhs); }
345#ifdef __cpp_lib_three_way_comparison
359#ifdef __cpp_lib_bit_cast
414 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
419 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
451 {
return lhs.m_order == 0; }
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; }
476 {
return 0 == rhs.m_order; }
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; }
499#ifdef __cpp_lib_three_way_comparison
511 {
return lhs.m_order == rhs.m_order; }
514 {
return lhs.m_order != rhs.m_order; }
517 {
return static_cast<partial_ordering>(lhs) == rhs; }
520 {
return static_cast<partial_ordering>(lhs) == rhs; }
523 {
return lhs ==
static_cast<partial_ordering>(rhs); }
526 {
return lhs !=
static_cast<partial_ordering>(rhs); }
529 {
return static_cast<weak_ordering>(lhs) == rhs; }
532 {
return static_cast<weak_ordering>(lhs) == rhs; }
535 {
return lhs ==
static_cast<weak_ordering>(rhs); }
538 {
return lhs !=
static_cast<weak_ordering>(rhs); }
540#ifdef __cpp_lib_three_way_comparison
556#ifdef __cpp_lib_bit_cast
609 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
614 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
633QT_BEGIN_INCLUDE_NAMESPACE
637#include <QtCore/qcomparehelpers.h>
639QT_END_INCLUDE_NAMESPACE
643template <
typename LeftType,
typename RightType>
644auto qCompareThreeWay(
const LeftType &lhs,
const RightType &rhs);
648template <
typename LT,
typename RT,
650 QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay<LT, RT>
651 || QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay<RT, LT>,
653auto qCompareThreeWay(
const LT &lhs,
const RT &rhs)
654 noexcept(QtOrderingPrivate::CompareThreeWayTester::compareThreeWayNoexcept<LT, RT>())
656 using Qt::compareThreeWay;
657 if constexpr (QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay<LT, RT>) {
658 return compareThreeWay(lhs, rhs);
660 const auto retval = compareThreeWay(rhs, lhs);
661 return QtOrderingPrivate::reversed(retval);
694 {
return lhs.isOrdered() && lhs.m_order == 0; }
698 {
return !lhs.isOrdered() || lhs.m_order != 0; }
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; }
719 {
return rhs.isOrdered() && 0 == rhs.m_order; }
723 {
return !rhs.isOrdered() || 0 != rhs.m_order; }
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; }
742#ifdef __cpp_lib_three_way_comparison
754 {
return lhs.m_order == rhs.m_order; }
757 {
return lhs.m_order != rhs.m_order; }
788#if !defined(Q_CC_GNU_ONLY) || (Q_CC_GNU >= 900
)
807#ifdef __cpp_lib_three_way_comparison
855 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
858 : m_order(
static_cast<QtPrivate::CompareUnderlyingType>(order))
863 QT_WARNING_DISABLE_GCC(
"-Wzero-as-null-pointer-constant")
874 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