diff --git a/src/corelib/global/qcompare.h b/src/corelib/global/qcompare.h index 0966cdfe9e..cda5b4c595 100644 --- a/src/corelib/global/qcompare.h +++ b/src/corelib/global/qcompare.h @@ -641,14 +641,15 @@ auto qCompareThreeWay(const LeftType &lhs, const RightType &rhs); template - || QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay, + std::disjunction_v< + QtOrderingPrivate::CompareThreeWayTester::HasCompareThreeWay, + QtOrderingPrivate::CompareThreeWayTester::HasCompareThreeWay>, bool> = true> auto qCompareThreeWay(const LT &lhs, const RT &rhs) noexcept(QtOrderingPrivate::CompareThreeWayTester::compareThreeWayNoexcept()) { using Qt::compareThreeWay; - if constexpr (QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay) { + if constexpr (QtOrderingPrivate::CompareThreeWayTester::hasCompareThreeWay_v) { 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 dcaa886bcd..a44569aa72 100644 --- a/src/corelib/global/qcomparehelpers.h +++ b/src/corelib/global/qcomparehelpers.h @@ -873,12 +873,15 @@ using Qt::compareThreeWay; // Check if compareThreeWay is implemented for the (LT, RT) argument // pair. template -constexpr inline bool hasCompareThreeWay = false; +struct HasCompareThreeWay : std::false_type {}; template -constexpr inline bool hasCompareThreeWay< +struct HasCompareThreeWay< LT, RT, std::void_t(), std::declval()))> - > = true; + > : std::true_type {}; + +template +constexpr inline bool hasCompareThreeWay_v = HasCompareThreeWay::value; // Check if the operation is noexcept. We have two different overloads, // depending on the available compareThreeWay() implementation. @@ -886,12 +889,13 @@ constexpr inline bool hasCompareThreeWay< // context. template , bool> = true> + std::enable_if_t, bool> = true> constexpr bool compareThreeWayNoexcept() noexcept { return noexcept(compareThreeWay(std::declval(), std::declval())); } template && hasCompareThreeWay, + std::enable_if_t>, + HasCompareThreeWay>, bool> = true> constexpr bool compareThreeWayNoexcept() noexcept { return noexcept(compareThreeWay(std::declval(), std::declval())); }