Skip to content

Commit

Permalink
Revert "Convert a Qt ordering type to the weaker std ordering type"
Browse files Browse the repository at this point in the history
This reverts commit 521e091.

Reason for revert: The fix doesn't work with MSVC2022 compiler and block windows-11_23H2-msvc2022-developer-build integration. Need time to find proper solution.

Pick-to: 6.8
Task-number: QTBUG-128498
Change-Id: Id938fa2119c7e4c053398b2a3693f3128e53f734
Reviewed-by: Ivan Solovev <[email protected]>
  • Loading branch information
qt-tatiana committed Sep 2, 2024
1 parent 248a1ce commit 1017a0e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 73 deletions.
59 changes: 0 additions & 59 deletions src/corelib/global/qcompare.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@

QT_BEGIN_NAMESPACE

#if defined(Q_CC_MSVC)
#define Q_COMPARE_CAST_IMPLICIT explicit
#else
#define Q_COMPARE_CAST_IMPLICIT Q_IMPLICIT
#endif // Q_CC_MSVC

namespace QtPrivate {
using CompareUnderlyingType = qint8;

Expand Down Expand Up @@ -376,23 +370,6 @@ class weak_ordering
#endif // __cpp_lib_bit_cast
}

constexpr Q_COMPARE_CAST_IMPLICIT operator std::partial_ordering() const noexcept
{
static_assert(sizeof(*this) == sizeof(std::partial_ordering));
#ifdef __cpp_lib_bit_cast
return std::bit_cast<std::partial_ordering>(*this);
#else
using O = QtPrivate::Ordering;
using R = std::partial_ordering;
switch (m_order) {
case qToUnderlying(O::Less): return R::less;
case qToUnderlying(O::Greater): return R::greater;
case qToUnderlying(O::Equivalent): return R::equivalent;
}
Q_UNREACHABLE_RETURN(R::unordered);
#endif // __cpp_lib_bit_cast
}

friend constexpr bool operator==(weak_ordering lhs, std::weak_ordering rhs) noexcept
{ return static_cast<std::weak_ordering>(lhs) == rhs; }

Expand Down Expand Up @@ -590,40 +567,6 @@ class strong_ordering
#endif // __cpp_lib_bit_cast
}

constexpr Q_COMPARE_CAST_IMPLICIT operator std::weak_ordering() const noexcept
{
static_assert(sizeof(*this) == sizeof(std::weak_ordering));
#ifdef __cpp_lib_bit_cast
return std::bit_cast<std::weak_ordering>(*this);
#else
using O = QtPrivate::Ordering;
using R = std::weak_ordering;
switch (m_order) {
case qToUnderlying(O::Less): return R::less;
case qToUnderlying(O::Greater): return R::greater;
case qToUnderlying(O::Equal): return R::equivalent;
}
Q_UNREACHABLE_RETURN(R::equivalent);
#endif // __cpp_lib_bit_cast
}

constexpr Q_COMPARE_CAST_IMPLICIT operator std::partial_ordering() const noexcept
{
static_assert(sizeof(*this) == sizeof(std::partial_ordering));
#ifdef __cpp_lib_bit_cast
return std::bit_cast<std::partial_ordering>(*this);
#else
using O = QtPrivate::Ordering;
using R = std::partial_ordering;
switch (m_order) {
case qToUnderlying(O::Less): return R::less;
case qToUnderlying(O::Greater): return R::greater;
case qToUnderlying(O::Equal): return R::equivalent;
}
Q_UNREACHABLE_RETURN(R::unordered);
#endif // __cpp_lib_bit_cast
}

friend constexpr bool operator==(strong_ordering lhs, std::strong_ordering rhs) noexcept
{ return static_cast<std::strong_ordering>(lhs) == rhs; }

Expand Down Expand Up @@ -979,8 +922,6 @@ inline constexpr QPartialOrdering QPartialOrdering::equivalent(QtPrivate::Orderi
inline constexpr QPartialOrdering QPartialOrdering::greater(QtPrivate::Ordering::Greater);
inline constexpr QPartialOrdering QPartialOrdering::unordered(QtPrivate::LegacyUncomparable::Unordered);

#undef Q_COMPARE_CAST_IMPLICIT

QT_END_NAMESPACE

#endif // QCOMPARE_H
14 changes: 0 additions & 14 deletions tests/auto/corelib/global/qcompare/tst_qcompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,20 +693,6 @@ void tst_QCompare::conversions()
static_assert(Qt::partial_ordering::less == std::weak_ordering::less);
static_assert(Qt::partial_ordering::equivalent == std::strong_ordering::equivalent);
static_assert(Qt::partial_ordering::equivalent != std::strong_ordering::less);

// convert Qt::strong to std::partial
constexpr Qt::strong_ordering qtS = Qt::strong_ordering::less;
constexpr std::partial_ordering stdP1 = qtS;
static_assert(stdP1 == qtS);

// convert Qt::strong to std::weak
constexpr std::weak_ordering stdW = qtS;
static_assert(stdW == qtS);

// convert Qt::weak to std::partial
constexpr Qt::weak_ordering qtW = Qt::weak_ordering::greater;
constexpr std::partial_ordering stdP2 = qtW;
static_assert(stdP2 == qtW);
}
#endif

Expand Down

0 comments on commit 1017a0e

Please sign in to comment.