QMetaType: Silence float comparison warnings in QEqualityOperatorForType

We actually do want to invoke the original equality operator there. If
that is unsafe, we cannot do much about it at this point.

Change-Id: Iadb2eaba1156828d89022d282c41bda57b500b13
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann 2020-10-15 08:54:48 +02:00
parent b3f3ebc2c0
commit 7745b49b2d
2 changed files with 6 additions and 0 deletions

View File

@ -250,11 +250,14 @@ struct is_container<T, std::void_t<
// Checks the existence of the comparison operator for the class itself
QT_WARNING_PUSH
QT_WARNING_DISABLE_FLOAT_COMPARE
template <typename, typename = void>
struct has_operator_equal : std::false_type {};
template <typename T>
struct has_operator_equal<T, std::void_t<decltype(bool(std::declval<const T&>() == std::declval<const T&>()))>>
: std::true_type {};
QT_WARNING_POP
// Two forward declarations
template<typename T, bool = is_container<T>::value>

View File

@ -2121,8 +2121,11 @@ struct BuiltinMetaType<T, std::enable_if_t<QMetaTypeId2<T>::IsBuiltIn>>
template<typename T, bool = (QTypeTraits::has_operator_equal_v<T> && !std::is_pointer_v<T>)>
struct QEqualityOperatorForType
{
QT_WARNING_PUSH
QT_WARNING_DISABLE_FLOAT_COMPARE
static bool equals(const QMetaTypeInterface *, const void *a, const void *b)
{ return *reinterpret_cast<const T *>(a) == *reinterpret_cast<const T *>(b); }
QT_WARNING_POP
};
template<typename T>