diff --git a/src/corelib/global/qcompare.h b/src/corelib/global/qcompare.h index fd9fb84c6b9..7fbf9aabcb3 100644 --- a/src/corelib/global/qcompare.h +++ b/src/corelib/global/qcompare.h @@ -629,42 +629,6 @@ QT_BEGIN_INCLUDE_NAMESPACE QT_END_INCLUDE_NAMESPACE -namespace QtPrivate { - -namespace CompareThreeWayTester { - - using Qt::compareThreeWay; - - // Check if compareThreeWay is implemented for the (LT, RT) argument - // pair. - template - constexpr bool hasCompareThreeWay = false; - - template - constexpr bool hasCompareThreeWay< - LT, RT, std::void_t(), std::declval()))> - > = true; - - // Check if the operation is noexcept. We have two different overloads, - // depending on the available compareThreeWay() implementation. - // Both are declared, but not implemented. To be used only in unevaluated - // context. - - template , bool> = true> - constexpr bool compareThreeWayNoexcept() noexcept - { return noexcept(compareThreeWay(std::declval(), std::declval())); } - - template && hasCompareThreeWay, - bool> = true> - constexpr bool compareThreeWayNoexcept() noexcept - { return noexcept(compareThreeWay(std::declval(), std::declval())); } - -} // namespace CompareThreeWayTester - -} // namespace QtPrivate - #if defined(Q_QDOC) template @@ -673,14 +637,15 @@ auto qCompareThreeWay(const LeftType &lhs, const RightType &rhs); #else template - || QtPrivate::CompareThreeWayTester::hasCompareThreeWay, - bool> = true> + std::enable_if_t< + QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay + || QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay, + bool> = true> auto qCompareThreeWay(const LT &lhs, const RT &rhs) - noexcept(QtPrivate::CompareThreeWayTester::compareThreeWayNoexcept()) + noexcept(QtOrderingPrivate::CompareThreeWayTester::compareThreeWayNoexcept()) { using Qt::compareThreeWay; - if constexpr (QtPrivate::CompareThreeWayTester::hasCompareThreeWay) { + if constexpr (QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay) { return compareThreeWay(lhs, rhs); } else { const auto retval = compareThreeWay(rhs, lhs); diff --git a/src/corelib/global/qcomparehelpers.h b/src/corelib/global/qcomparehelpers.h index 8bf78d766bc..dcaa886bcdd 100644 --- a/src/corelib/global/qcomparehelpers.h +++ b/src/corelib/global/qcomparehelpers.h @@ -864,6 +864,42 @@ compareThreeWay(std::nullptr_t lhs, Qt::totally_ordered_wrapper rhs) noexcep template class QTypeInfo> : public QTypeInfo

{}; +namespace QtOrderingPrivate { + +namespace CompareThreeWayTester { + +using Qt::compareThreeWay; + +// Check if compareThreeWay is implemented for the (LT, RT) argument +// pair. +template +constexpr inline bool hasCompareThreeWay = false; + +template +constexpr inline bool hasCompareThreeWay< + LT, RT, std::void_t(), std::declval()))> + > = true; + +// Check if the operation is noexcept. We have two different overloads, +// depending on the available compareThreeWay() implementation. +// Both are declared, but not implemented. To be used only in unevaluated +// context. + +template , bool> = true> +constexpr bool compareThreeWayNoexcept() noexcept +{ return noexcept(compareThreeWay(std::declval(), std::declval())); } + +template && hasCompareThreeWay, + bool> = true> +constexpr bool compareThreeWayNoexcept() noexcept +{ return noexcept(compareThreeWay(std::declval(), std::declval())); } + +} // namespace CompareThreeWayTester + +} // namespace QtOrderingPrivate + QT_END_NAMESPACE namespace std {