qHash overload for Q{Explicitly,}SharedDataPointer
Interestingly, before that patch this compiled fine: typedef Q{Explicitly,}SharedDataPointer<QSharedData> Ptr; Ptr p(new QSharedData); auto hash = qHash(p); This was because both Q{Explicitly,}SharedDataPointer overload 'operator bool()' => qHash(int) was accepted. This, however, doesn't make sense. Someone should probably take care of applying the safe bool idiom to these classes as well. Change-Id: I8bb6b2aacaa6166da817a6f3847093fd20a05a67 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
28e5158026
commit
62620a4d6a
@ -44,6 +44,7 @@
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore/qatomic.h>
|
||||
#include <QtCore/qhash.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -274,6 +275,17 @@ namespace std {
|
||||
}
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
template <class T>
|
||||
Q_INLINE_TEMPLATE uint qHash(const QSharedDataPointer<T> &ptr, uint seed = 0)
|
||||
{
|
||||
return qHash(ptr.data(), seed);
|
||||
}
|
||||
template <class T>
|
||||
Q_INLINE_TEMPLATE uint qHash(const QExplicitlySharedDataPointer<T> &ptr, uint seed = 0)
|
||||
{
|
||||
return qHash(ptr.data(), seed);
|
||||
}
|
||||
|
||||
template<typename T> Q_DECLARE_TYPEINFO_BODY(QSharedDataPointer<T>, Q_MOVABLE_TYPE);
|
||||
template<typename T> Q_DECLARE_TYPEINFO_BODY(QExplicitlySharedDataPointer<T>, Q_MOVABLE_TYPE);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user