QMetaType: Add qHash() overload
This is needed for use in QHash and similar. It's essentially the same as using the integer id, but typesafe Change-Id: I9515b8e178c8f9828934cb0bb099cce5553ec393 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
d2d202c648
commit
d72f2ca9ea
@ -3002,6 +3002,14 @@ static const QtPrivate::QMetaTypeInterface *interfaceForType(int typeId)
|
|||||||
*/
|
*/
|
||||||
QMetaType::QMetaType(int typeId) : QMetaType(interfaceForType(typeId)) {}
|
QMetaType::QMetaType(int typeId) : QMetaType(interfaceForType(typeId)) {}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \fn size_t qHash(QMetaType type, size_t seed = 0)
|
||||||
|
\relates QMetaType
|
||||||
|
\since 6.4
|
||||||
|
|
||||||
|
Returns the hash value for the \a type, using \a seed to seed the calculation.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace QtPrivate {
|
namespace QtPrivate {
|
||||||
#if !defined(QT_BOOTSTRAPPED) && !defined(Q_CC_MSVC)
|
#if !defined(QT_BOOTSTRAPPED) && !defined(Q_CC_MSVC)
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
#ifndef QT_NO_QOBJECT
|
#ifndef QT_NO_QOBJECT
|
||||||
#include <QtCore/qobjectdefs.h>
|
#include <QtCore/qobjectdefs.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <QtCore/qhashfunctions.h>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <new>
|
#include <new>
|
||||||
@ -2536,6 +2537,13 @@ constexpr const QtPrivate::QMetaTypeInterface *const qt_incomplete_metaTypeArray
|
|||||||
QtPrivate::qTryMetaTypeInterfaceForType<Unique, T>()...
|
QtPrivate::qTryMetaTypeInterfaceForType<Unique, T>()...
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline size_t qHash(QMetaType type, size_t seed = 0)
|
||||||
|
{
|
||||||
|
// We cannot use d_ptr here since the same type in different DLLs
|
||||||
|
// might result in different pointers!
|
||||||
|
return qHash(type.id(), seed);
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
QT_DECL_METATYPE_EXTERN_TAGGED(QtMetaTypePrivate::QPairVariantInterfaceImpl,
|
QT_DECL_METATYPE_EXTERN_TAGGED(QtMetaTypePrivate::QPairVariantInterfaceImpl,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user