summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qcomparehelpers.h
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-09-26 17:11:03 +0200
committerIvan Solovev <ivan.solovev@qt.io>2023-12-07 06:16:23 +0100
commit4b755bc11a8eadd156c65b7474c11e3ce822c6f1 (patch)
treeababb9850d6b71512481577749e3bff992414dde /src/corelib/global/qcomparehelpers.h
parentd677a454b208dfccc16c845d114575a414ca284f (diff)
Teach Qt::compareThreeWay() to support native float16 types
Provide a custom variable template to detect float types and specialize it for QtPrivate::NativeFloat16Type. This will allow to enable three-way comparison for qfloat16. Task-number: QTBUG-104113 Change-Id: Id12c42c86f8dc9e233fe39776b0f0e28088de9e1 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/global/qcomparehelpers.h')
-rw-r--r--src/corelib/global/qcomparehelpers.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/corelib/global/qcomparehelpers.h b/src/corelib/global/qcomparehelpers.h
index 9c9da2c7d9..ad21d461b9 100644
--- a/src/corelib/global/qcomparehelpers.h
+++ b/src/corelib/global/qcomparehelpers.h
@@ -341,6 +341,14 @@ template <typename T>
constexpr bool IsIntegralType_v = std::numeric_limits<std::remove_const_t<T>>::is_specialized
&& std::numeric_limits<std::remove_const_t<T>>::is_integer;
+template <typename T>
+constexpr bool IsFloatType_v = std::is_floating_point_v<T>;
+
+#if QFLOAT16_IS_NATIVE
+template <>
+constexpr bool IsFloatType_v<QtPrivate::NativeFloat16Type> = true;
+#endif
+
} // namespace QtPrivate
namespace Qt {
@@ -353,14 +361,14 @@ using if_integral =
template <typename T, typename U>
using if_floating_point =
- std::enable_if_t<std::conjunction_v<std::is_floating_point<std::remove_reference_t<T>>,
- std::is_floating_point<std::remove_reference_t<U>>>,
+ std::enable_if_t<QtPrivate::IsFloatType_v<std::remove_reference_t<T>>
+ && QtPrivate::IsFloatType_v<std::remove_reference_t<U>>,
bool>;
template <typename T, typename U>
using if_integral_and_floating_point =
std::enable_if_t<QtPrivate::IsIntegralType_v<std::remove_reference_t<T>>
- && std::is_floating_point_v<std::remove_reference_t<U>>,
+ && QtPrivate::IsFloatType_v<std::remove_reference_t<U>>,
bool>;
template <typename T, typename U>