summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qcomparehelpers.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-11-28 11:35:18 +0100
committerIvan Solovev <ivan.solovev@qt.io>2023-12-07 06:16:23 +0100
commit091793ccaa5b11d91252a15e8452d6544e4e3504 (patch)
tree5387342b94cd7ce175cc07e7c702d0520b0620f1 /src/corelib/global/qcomparehelpers.h
parent4b755bc11a8eadd156c65b7474c11e3ce822c6f1 (diff)
qcomparehelper.h: simplify compareThreeWay() SFINAE helpers
There's no restriction on the number of enable_if's in a template-initializer, so simplify the compareThreeWay() constraints by having separate constraints each for LeftType and RightType. Fewer templates to instantiate = faster compile speed. As a drive-by, drop remove_reference_t. We control all users and all of them pass already-decayed types. Change-Id: I17c01c7aa1ac03bb6db4b0bef1371ebc0641641d Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/corelib/global/qcomparehelpers.h')
-rw-r--r--src/corelib/global/qcomparehelpers.h32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/corelib/global/qcomparehelpers.h b/src/corelib/global/qcomparehelpers.h
index ad21d461b9..d7e007b8b0 100644
--- a/src/corelib/global/qcomparehelpers.h
+++ b/src/corelib/global/qcomparehelpers.h
@@ -353,23 +353,11 @@ constexpr bool IsFloatType_v<QtPrivate::NativeFloat16Type> = true;
namespace Qt {
-template <typename T, typename U>
-using if_integral =
- std::enable_if_t<QtPrivate::IsIntegralType_v<std::remove_reference_t<T>>
- && QtPrivate::IsIntegralType_v<std::remove_reference_t<U>>,
- bool>;
-
-template <typename T, typename U>
-using if_floating_point =
- std::enable_if_t<QtPrivate::IsFloatType_v<std::remove_reference_t<T>>
- && QtPrivate::IsFloatType_v<std::remove_reference_t<U>>,
- bool>;
+template <typename T>
+using if_integral = std::enable_if_t<QtPrivate::IsIntegralType_v<T>, bool>;
-template <typename T, typename U>
-using if_integral_and_floating_point =
- std::enable_if_t<QtPrivate::IsIntegralType_v<std::remove_reference_t<T>>
- && QtPrivate::IsFloatType_v<std::remove_reference_t<U>>,
- bool>;
+template <typename T>
+using if_floating_point = std::enable_if_t<QtPrivate::IsFloatType_v<T>, bool>;
template <typename T, typename U>
using if_compatible_pointers =
@@ -382,7 +370,8 @@ template <typename Enum>
using if_enum = std::enable_if_t<std::is_enum_v<Enum>, bool>;
template <typename LeftInt, typename RightInt,
- if_integral<LeftInt, RightInt> = true>
+ if_integral<LeftInt> = true,
+ if_integral<RightInt> = true>
constexpr Qt::strong_ordering compareThreeWay(LeftInt lhs, RightInt rhs) noexcept
{
static_assert(std::is_signed_v<LeftInt> == std::is_signed_v<RightInt>,
@@ -401,7 +390,8 @@ constexpr Qt::strong_ordering compareThreeWay(LeftInt lhs, RightInt rhs) noexcep
}
template <typename LeftFloat, typename RightFloat,
- if_floating_point<LeftFloat, RightFloat> = true>
+ if_floating_point<LeftFloat> = true,
+ if_floating_point<RightFloat> = true>
constexpr Qt::partial_ordering compareThreeWay(LeftFloat lhs, RightFloat rhs) noexcept
{
QT_WARNING_PUSH
@@ -422,14 +412,16 @@ QT_WARNING_POP
}
template <typename IntType, typename FloatType,
- if_integral_and_floating_point<IntType, FloatType> = true>
+ if_integral<IntType> = true,
+ if_floating_point<FloatType> = true>
constexpr Qt::partial_ordering compareThreeWay(IntType lhs, FloatType rhs) noexcept
{
return compareThreeWay(FloatType(lhs), rhs);
}
template <typename FloatType, typename IntType,
- if_integral_and_floating_point<IntType, FloatType> = true>
+ if_floating_point<FloatType> = true,
+ if_integral<IntType> = true>
constexpr Qt::partial_ordering compareThreeWay(FloatType lhs, IntType rhs) noexcept
{
return compareThreeWay(lhs, FloatType(rhs));