diff --git a/src/corelib/global/qcompare.h b/src/corelib/global/qcompare.h index 49c0a0ce9d0..a807e6001c8 100644 --- a/src/corelib/global/qcompare.h +++ b/src/corelib/global/qcompare.h @@ -88,7 +88,7 @@ class partial_ordering friend constexpr bool operator!=(partial_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept - { return lhs.isOrdered() && lhs.m_order != 0; } + { return !lhs.isOrdered() || lhs.m_order != 0; } friend constexpr bool operator< (partial_ordering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept @@ -113,7 +113,7 @@ class partial_ordering friend constexpr bool operator!=(QtPrivate::CompareAgainstLiteralZero, partial_ordering rhs) noexcept - { return rhs.isOrdered() && 0 != rhs.m_order; } + { return !rhs.isOrdered() || 0 != rhs.m_order; } friend constexpr bool operator< (QtPrivate::CompareAgainstLiteralZero, partial_ordering rhs) noexcept @@ -730,7 +730,7 @@ class QPartialOrdering friend constexpr bool operator!=(QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept - { return lhs.isOrdered() && lhs.m_order != 0; } + { return !lhs.isOrdered() || lhs.m_order != 0; } friend constexpr bool operator< (QPartialOrdering lhs, QtPrivate::CompareAgainstLiteralZero) noexcept @@ -755,7 +755,7 @@ class QPartialOrdering friend constexpr bool operator!=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept - { return rhs.isOrdered() && 0 != rhs.m_order; } + { return !rhs.isOrdered() || 0 != rhs.m_order; } friend constexpr bool operator< (QtPrivate::CompareAgainstLiteralZero, QPartialOrdering rhs) noexcept diff --git a/tests/auto/corelib/global/qcompare/tst_qcompare.cpp b/tests/auto/corelib/global/qcompare/tst_qcompare.cpp index d28833abb16..8d764ad5257 100644 --- a/tests/auto/corelib/global/qcompare/tst_qcompare.cpp +++ b/tests/auto/corelib/global/qcompare/tst_qcompare.cpp @@ -53,21 +53,21 @@ void tst_QCompare::legacyPartialOrdering() static_assert(QPartialOrdering::Greater == QPartialOrdering::Greater); static_assert(!is_eq (QPartialOrdering::Unordered)); - static_assert(!is_neq (QPartialOrdering::Unordered)); + static_assert( is_neq (QPartialOrdering::Unordered)); static_assert(!is_lt (QPartialOrdering::Unordered)); static_assert(!is_lteq(QPartialOrdering::Unordered)); static_assert(!is_gt (QPartialOrdering::Unordered)); static_assert(!is_gteq(QPartialOrdering::Unordered)); static_assert(!(QPartialOrdering::Unordered == 0)); - static_assert(!(QPartialOrdering::Unordered != 0)); + static_assert( (QPartialOrdering::Unordered != 0)); static_assert(!(QPartialOrdering::Unordered < 0)); static_assert(!(QPartialOrdering::Unordered <= 0)); static_assert(!(QPartialOrdering::Unordered > 0)); static_assert(!(QPartialOrdering::Unordered >= 0)); static_assert(!(0 == QPartialOrdering::Unordered)); - static_assert(!(0 != QPartialOrdering::Unordered)); + static_assert( (0 != QPartialOrdering::Unordered)); static_assert(!(0 < QPartialOrdering::Unordered)); static_assert(!(0 <= QPartialOrdering::Unordered)); static_assert(!(0 > QPartialOrdering::Unordered)); @@ -225,21 +225,21 @@ void tst_QCompare::partialOrdering() static_assert(Qt::partial_ordering::greater == Qt::partial_ordering::greater); static_assert(!is_eq (Qt::partial_ordering::unordered)); - static_assert(!is_neq (Qt::partial_ordering::unordered)); + static_assert( is_neq (Qt::partial_ordering::unordered)); static_assert(!is_lt (Qt::partial_ordering::unordered)); static_assert(!is_lteq(Qt::partial_ordering::unordered)); static_assert(!is_gt (Qt::partial_ordering::unordered)); static_assert(!is_gteq(Qt::partial_ordering::unordered)); static_assert(!(Qt::partial_ordering::unordered == 0)); - static_assert(!(Qt::partial_ordering::unordered != 0)); + static_assert( (Qt::partial_ordering::unordered != 0)); static_assert(!(Qt::partial_ordering::unordered < 0)); static_assert(!(Qt::partial_ordering::unordered <= 0)); static_assert(!(Qt::partial_ordering::unordered > 0)); static_assert(!(Qt::partial_ordering::unordered >= 0)); static_assert(!(0 == Qt::partial_ordering::unordered)); - static_assert(!(0 != Qt::partial_ordering::unordered)); + static_assert( (0 != Qt::partial_ordering::unordered)); static_assert(!(0 < Qt::partial_ordering::unordered)); static_assert(!(0 <= Qt::partial_ordering::unordered)); static_assert(!(0 > Qt::partial_ordering::unordered)); @@ -859,32 +859,20 @@ void tst_QCompare::unorderedNeqLiteralZero() QVERIFY(0 != stdUnordered); QVERIFY(is_neq(stdUnordered)); - QEXPECT_FAIL("", "QTBUG-127759", Continue); QCOMPARE_EQ(qtUnordered != 0, stdUnordered != 0); - QEXPECT_FAIL("", "QTBUG-127759", Continue); QCOMPARE_EQ(0 != qtUnordered, 0 != stdUnordered); - QEXPECT_FAIL("", "QTBUG-127759", Continue); QCOMPARE_EQ(is_neq(qtUnordered), is_neq(stdUnordered)); - QEXPECT_FAIL("", "QTBUG-127759", Continue); QCOMPARE_EQ(qtLegacyUnordered != 0, stdUnordered != 0); - QEXPECT_FAIL("", "QTBUG-127759", Continue); QCOMPARE_EQ(0 != qtLegacyUnordered, 0 != stdUnordered); - QEXPECT_FAIL("", "QTBUG-127759", Continue); QCOMPARE_EQ(is_neq(qtLegacyUnordered), is_neq(stdUnordered)); #endif - QEXPECT_FAIL("", "QTBUG-127759", Continue); QVERIFY(qtUnordered != 0); - QEXPECT_FAIL("", "QTBUG-127759", Continue); QVERIFY(0 != qtUnordered); - QEXPECT_FAIL("", "QTBUG-127759", Continue); QVERIFY(is_neq(qtUnordered)); - QEXPECT_FAIL("", "QTBUG-127759", Continue); QVERIFY(qtLegacyUnordered != 0); - QEXPECT_FAIL("", "QTBUG-127759", Continue); QVERIFY(0 != qtLegacyUnordered); - QEXPECT_FAIL("", "QTBUG-127759", Continue); QVERIFY(is_neq(qtLegacyUnordered)); }