Change qHash() to work with size_t instead of uint

This is required, so that QHash and QSet can hold more
than 2^32 items on 64 bit platforms.

The actual hashing functions for strings are still 32bit, this will
be changed in a follow-up commit.

Change-Id: I4372125252486075ff3a0b45ecfa818359fe103b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Lars Knoll 2020-01-31 12:11:54 +01:00
parent 775945137b
commit c6cdf38e75
125 changed files with 305 additions and 310 deletions

View File

@ -53,7 +53,7 @@
#include "slippymap.h" #include "slippymap.h"
#include "qmath.h" #include "qmath.h"
uint qHash(const QPoint& p) size_t qHash(const QPoint& p)
{ {
return p.x() * 17 ^ p.y(); return p.x() * 17 ^ p.y();
} }

View File

@ -173,7 +173,7 @@ QString LanguageChooser::languageName(const QString &qmFile)
QColor LanguageChooser::colorForLanguage(const QString &language) QColor LanguageChooser::colorForLanguage(const QString &language)
{ {
uint hashValue = qHash(language); size_t hashValue = qHash(language);
int red = 156 + (hashValue & 0x3F); int red = 156 + (hashValue & 0x3F);
int green = 156 + ((hashValue >> 6) & 0x3F); int green = 156 + ((hashValue >> 6) & 0x3F);
int blue = 156 + ((hashValue >> 12) & 0x3F); int blue = 156 + ((hashValue >> 12) & 0x3F);

View File

@ -64,7 +64,7 @@ struct FixStringCacheKey
return hash; return hash;
} }
}; };
inline uint qHash(const FixStringCacheKey &f) { return f.hashCode(); } inline size_t qHash(const FixStringCacheKey &f) { return f.hashCode(); }
// ------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------
struct FileInfoCacheKey struct FileInfoCacheKey
@ -102,7 +102,7 @@ struct FileInfoCacheKey
|| (c0 == QLatin1Char('\\') && c1 == QLatin1Char('\\'))); || (c0 == QLatin1Char('\\') && c1 == QLatin1Char('\\')));
} }
}; };
inline uint qHash(const FileInfoCacheKey &f) { return f.hashCode(); } inline size_t qHash(const FileInfoCacheKey &f) { return f.hashCode(); }
// ------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------
template <typename T> template <typename T>

View File

@ -306,13 +306,13 @@ struct ReplaceExtraCompilerCacheKey
MakefileGenerator::ReplaceFor forShell; MakefileGenerator::ReplaceFor forShell;
ReplaceExtraCompilerCacheKey(const QString &v, const QStringList &i, const QStringList &o, MakefileGenerator::ReplaceFor s); ReplaceExtraCompilerCacheKey(const QString &v, const QStringList &i, const QStringList &o, MakefileGenerator::ReplaceFor s);
bool operator==(const ReplaceExtraCompilerCacheKey &f) const; bool operator==(const ReplaceExtraCompilerCacheKey &f) const;
inline uint hashCode() const { inline size_t hashCode() const {
if (!hash) if (!hash)
hash = (uint)forShell ^ qHash(var) ^ qHash(in) ^ qHash(out) /*^ qHash(pwd)*/; hash = (size_t)forShell ^ qHash(var) ^ qHash(in) ^ qHash(out) /*^ qHash(pwd)*/;
return hash; return hash;
} }
}; };
inline uint qHash(const ReplaceExtraCompilerCacheKey &f) { return f.hashCode(); } inline size_t qHash(const ReplaceExtraCompilerCacheKey &f) { return f.hashCode(); }
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -116,7 +116,7 @@ uint ProString::updatedHash() const
return (m_hash = hash(m_string.constData() + m_offset, m_length)); return (m_hash = hash(m_string.constData() + m_offset, m_length));
} }
uint qHash(const ProString &str) size_t qHash(const ProString &str)
{ {
if (!(str.m_hash & 0x80000000)) if (!(str.m_hash & 0x80000000))
return str.m_hash; return str.m_hash;

View File

@ -173,7 +173,7 @@ private:
mutable uint m_hash; mutable uint m_hash;
QChar *prepareExtend(int extraLen, int thisTarget, int extraTarget); QChar *prepareExtend(int extraLen, int thisTarget, int extraTarget);
uint updatedHash() const; uint updatedHash() const;
friend uint qHash(const ProString &str); friend size_t qHash(const ProString &str);
friend QString operator+(const ProString &one, const ProString &two); friend QString operator+(const ProString &one, const ProString &two);
friend class ProKey; friend class ProKey;
}; };
@ -206,7 +206,7 @@ private:
}; };
Q_DECLARE_TYPEINFO(ProKey, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(ProKey, Q_MOVABLE_TYPE);
uint qHash(const ProString &str); size_t qHash(const ProString &str);
QString operator+(const ProString &one, const ProString &two); QString operator+(const ProString &one, const ProString &two);
inline QString operator+(const ProString &one, const QString &two) inline QString operator+(const ProString &one, const QString &two)
{ return one.toQStringRef() + two; } { return one.toQStringRef() + two; }

View File

@ -107,7 +107,7 @@ QMakeBaseKey::QMakeBaseKey(const QString &_root, const QString &_stash, bool _ho
{ {
} }
uint qHash(const QMakeBaseKey &key) size_t qHash(const QMakeBaseKey &key)
{ {
return qHash(key.root) ^ qHash(key.stash) ^ (uint)key.hostBuild; return qHash(key.root) ^ qHash(key.stash) ^ (uint)key.hostBuild;
} }

View File

@ -62,7 +62,7 @@ public:
bool hostBuild; bool hostBuild;
}; };
uint qHash(const QMakeBaseKey &key); size_t qHash(const QMakeBaseKey &key);
bool operator==(const QMakeBaseKey &one, const QMakeBaseKey &two); bool operator==(const QMakeBaseKey &one, const QMakeBaseKey &two);
class QMakeBaseEnv class QMakeBaseEnv

View File

@ -149,7 +149,7 @@ inline bool operator==(const Employee &e1, const Employee &e2)
&& e1.dateOfBirth() == e2.dateOfBirth(); && e1.dateOfBirth() == e2.dateOfBirth();
} }
inline uint qHash(const Employee &key, uint seed) inline size_t qHash(const Employee &key, size_t seed)
{ {
return qHash(key.name(), seed) ^ key.dateOfBirth().day(); return qHash(key.name(), seed) ^ key.dateOfBirth().day();
} }
@ -312,7 +312,7 @@ qDeleteAll(hash2.keyBegin(), hash2.keyEnd());
//! [28] //! [28]
//! [qhashbits] //! [qhashbits]
inline uint qHash(const std::vector<int> &key, uint seed = 0) inline size_t qHash(const std::vector<int> &key, size_t seed = 0)
{ {
if (key.empty()) if (key.empty())
return seed; return seed;
@ -322,14 +322,14 @@ inline uint qHash(const std::vector<int> &key, uint seed = 0)
//! [qhashbits] //! [qhashbits]
//! [qhashrange] //! [qhashrange]
inline uint qHash(const std::vector<int> &key, uint seed = 0) inline size_t qHash(const std::vector<int> &key, size_t seed = 0)
{ {
return qHashRange(key.begin(), key.end(), seed); return qHashRange(key.begin(), key.end(), seed);
} }
//! [qhashrange] //! [qhashrange]
//! [qhashrangecommutative] //! [qhashrangecommutative]
inline uint qHash(const std::unordered_set<int> &key, uint seed = 0) inline size_t qHash(const std::unordered_set<int> &key, size_t seed = 0)
{ {
return qHashRangeCommutative(key.begin(), key.end(), seed); return qHashRangeCommutative(key.begin(), key.end(), seed);
} }
@ -348,9 +348,9 @@ qHash(qMakePair(key.first, key.second), seed);
//! [31] //! [31]
//! [32] //! [32]
uint qHash(K key); size_t qHash(K key);
uint qHash(const K &key); size_t qHash(const K &key);
uint qHash(K key, uint seed); size_t qHash(K key, size_t seed);
uint qHash(const K &key, uint seed); size_t qHash(const K &key, size_t seed);
//! [32] //! [32]

View File

@ -142,7 +142,7 @@ public:
Q_DECLARE_TYPEINFO(QFileSystemWatcherPathKey, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QFileSystemWatcherPathKey, Q_MOVABLE_TYPE);
inline uint qHash(const QFileSystemWatcherPathKey &key) { return qHash(key.toCaseFolded()); } inline size_t qHash(const QFileSystemWatcherPathKey &key) { return qHash(key.toCaseFolded()); }
class QWindowsFileSystemWatcherEngineThread : public QThread class QWindowsFileSystemWatcherEngineThread : public QThread
{ {

View File

@ -4116,7 +4116,7 @@ QList<QUrl> QUrl::fromStringList(const QStringList &urls, ParsingMode mode)
\relates QHash \relates QHash
\since 5.0 \since 5.0
*/ */
uint qHash(const QUrl &url, uint seed) noexcept size_t qHash(const QUrl &url, size_t seed) noexcept
{ {
if (!url.d) if (!url.d)
return qHash(-1, seed); // the hash of an unset port (-1) return qHash(-1, seed); // the hash of an unset port (-1)

View File

@ -119,7 +119,7 @@ class QTypeInfo<QUrlTwoFlags<E1, E2> > : public QTypeInfoMerger<QUrlTwoFlags<E1,
class QUrl; class QUrl;
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed = 0) noexcept; Q_CORE_EXPORT size_t qHash(const QUrl &url, size_t seed = 0) noexcept;
class Q_CORE_EXPORT QUrl class Q_CORE_EXPORT QUrl
{ {
@ -356,7 +356,7 @@ public:
static QList<QUrl> fromStringList(const QStringList &uris, ParsingMode mode = TolerantMode); static QList<QUrl> fromStringList(const QStringList &uris, ParsingMode mode = TolerantMode);
static void setIdnWhitelist(const QStringList &); static void setIdnWhitelist(const QStringList &);
friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed) noexcept; friend Q_CORE_EXPORT size_t qHash(const QUrl &url, size_t seed) noexcept;
private: private:
QUrlPrivate *d; QUrlPrivate *d;

View File

@ -434,7 +434,7 @@ bool QUrlQuery::operator ==(const QUrlQuery &other) const
Returns the hash value for \a key, Returns the hash value for \a key,
using \a seed to seed the calculation. using \a seed to seed the calculation.
*/ */
uint qHash(const QUrlQuery &key, uint seed) noexcept size_t qHash(const QUrlQuery &key, size_t seed) noexcept
{ {
if (const QUrlQueryPrivate *d = key.d) { if (const QUrlQueryPrivate *d = key.d) {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;

View File

@ -52,7 +52,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed = 0) noexcept; Q_CORE_EXPORT size_t qHash(const QUrlQuery &key, size_t seed = 0) noexcept;
class QUrlQueryPrivate; class QUrlQueryPrivate;
class Q_CORE_EXPORT QUrlQuery class Q_CORE_EXPORT QUrlQuery
@ -109,7 +109,7 @@ public:
private: private:
friend class QUrl; friend class QUrl;
friend Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed) noexcept; friend Q_CORE_EXPORT size_t qHash(const QUrlQuery &key, size_t seed) noexcept;
QSharedDataPointer<QUrlQueryPrivate> d; QSharedDataPointer<QUrlQueryPrivate> d;
public: public:
typedef QSharedDataPointer<QUrlQueryPrivate> DataPtr; typedef QSharedDataPointer<QUrlQueryPrivate> DataPtr;

View File

@ -3978,7 +3978,7 @@ bool QAbstractListModel::dropMimeData(const QMimeData *data, Qt::DropAction acti
*/ */
/*! /*!
\fn uint qHash(const QPersistentModelIndex &index, uint seed = 0) \fn size_t qHash(const QPersistentModelIndex &index, size_t seed = 0)
\since 5.0 \since 5.0
\relates QPersistentModelIndex \relates QPersistentModelIndex

View File

@ -103,7 +103,7 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QModelIndex &);
class QPersistentModelIndexData; class QPersistentModelIndexData;
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
uint qHash(const QPersistentModelIndex &index, uint seed = 0) noexcept; size_t qHash(const QPersistentModelIndex &index, size_t seed = 0) noexcept;
class Q_CORE_EXPORT QPersistentModelIndex class Q_CORE_EXPORT QPersistentModelIndex
{ {
@ -141,14 +141,14 @@ public:
bool isValid() const; bool isValid() const;
private: private:
QPersistentModelIndexData *d; QPersistentModelIndexData *d;
friend uint qHash(const QPersistentModelIndex &, uint seed) noexcept; friend size_t qHash(const QPersistentModelIndex &, size_t seed) noexcept;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &); friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &);
#endif #endif
}; };
Q_DECLARE_SHARED(QPersistentModelIndex) Q_DECLARE_SHARED(QPersistentModelIndex)
inline uint qHash(const QPersistentModelIndex &index, uint seed) noexcept inline size_t qHash(const QPersistentModelIndex &index, size_t seed) noexcept
{ return qHash(index.d, seed); } { return qHash(index.d, seed); }
@ -461,8 +461,8 @@ inline QVariant QModelIndex::data(int arole) const
inline Qt::ItemFlags QModelIndex::flags() const inline Qt::ItemFlags QModelIndex::flags() const
{ return m ? m->flags(*this) : Qt::ItemFlags(); } { return m ? m->flags(*this) : Qt::ItemFlags(); }
inline uint qHash(const QModelIndex &index) noexcept inline size_t qHash(const QModelIndex &index, size_t seed) noexcept
{ return uint((uint(index.row()) << 4) + index.column() + index.internalId()); } { return size_t((size_t(index.row()) << 4) + size_t(index.column()) + index.internalId()) ^ seed; }
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -223,9 +223,6 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QItemSelectionModel::SelectionFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(QItemSelectionModel::SelectionFlags)
// dummy implentation of qHash() necessary for instantiating QList<QItemSelectionRange>::toSet() with MSVC
inline uint qHash(const QItemSelectionRange &) { return 0; }
#ifdef Q_CC_MSVC #ifdef Q_CC_MSVC
/* /*

View File

@ -192,7 +192,7 @@ bool QMimeType::operator==(const QMimeType &other) const
Returns the hash value for \a key, using Returns the hash value for \a key, using
\a seed to seed the calculation. \a seed to seed the calculation.
*/ */
uint qHash(const QMimeType &key, uint seed) noexcept size_t qHash(const QMimeType &key, size_t seed) noexcept
{ {
return qHash(key.d->name, seed); return qHash(key.d->name, seed);
} }

View File

@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
class QMimeTypePrivate; class QMimeTypePrivate;
class QMimeType; class QMimeType;
Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed = 0) noexcept; Q_CORE_EXPORT size_t qHash(const QMimeType &key, size_t seed = 0) noexcept;
class Q_CORE_EXPORT QMimeType class Q_CORE_EXPORT QMimeType
{ {
@ -119,7 +119,7 @@ protected:
friend class QMimeXMLProvider; friend class QMimeXMLProvider;
friend class QMimeBinaryProvider; friend class QMimeBinaryProvider;
friend class QMimeTypePrivate; friend class QMimeTypePrivate;
friend Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed) noexcept; friend Q_CORE_EXPORT size_t qHash(const QMimeType &key, size_t seed) noexcept;
QExplicitlySharedDataPointer<QMimeTypePrivate> d; QExplicitlySharedDataPointer<QMimeTypePrivate> d;
}; };

View File

@ -1089,7 +1089,7 @@ QDebug operator<<(QDebug dbg, const QUuid &id)
\relates QUuid \relates QUuid
Returns a hash of the UUID \a uuid, using \a seed to seed the calculation. Returns a hash of the UUID \a uuid, using \a seed to seed the calculation.
*/ */
uint qHash(const QUuid &uuid, uint seed) noexcept size_t qHash(const QUuid &uuid, size_t seed) noexcept
{ {
return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16) return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16)
^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3]) ^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3])

View File

@ -243,7 +243,7 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QUuid &);
Q_CORE_EXPORT QDebug operator<<(QDebug, const QUuid &); Q_CORE_EXPORT QDebug operator<<(QDebug, const QUuid &);
#endif #endif
Q_CORE_EXPORT uint qHash(const QUuid &uuid, uint seed = 0) noexcept; Q_CORE_EXPORT size_t qHash(const QUuid &uuid, size_t seed = 0) noexcept;
inline bool operator<=(const QUuid &lhs, const QUuid &rhs) noexcept inline bool operator<=(const QUuid &lhs, const QUuid &rhs) noexcept
{ return !(rhs < lhs); } { return !(rhs < lhs); }

View File

@ -1200,7 +1200,7 @@ void QCborArray::detach(qsizetype reserved)
Returns the offset of this iterator relative to \a other. Returns the offset of this iterator relative to \a other.
*/ */
uint qHash(const QCborArray &array, uint seed) size_t qHash(const QCborArray &array, size_t seed)
{ {
return qHashRange(array.begin(), array.end(), seed); return qHashRange(array.begin(), array.end(), seed);
} }

View File

@ -294,7 +294,7 @@ inline QCborArray QCborValueRef::toArray(const QCborArray &a) const
return concrete().toArray(a); return concrete().toArray(a);
} }
Q_CORE_EXPORT uint qHash(const QCborArray &array, uint seed = 0); Q_CORE_EXPORT size_t qHash(const QCborArray &array, size_t seed = 0);
#if !defined(QT_NO_DEBUG_STREAM) #if !defined(QT_NO_DEBUG_STREAM)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborArray &a); Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborArray &a);

View File

@ -138,12 +138,12 @@ QDataStream &operator<<(QDataStream &ds, QCborSimpleType st);
QDataStream &operator>>(QDataStream &ds, QCborSimpleType &st); QDataStream &operator>>(QDataStream &ds, QCborSimpleType &st);
#endif #endif
inline uint qHash(QCborSimpleType tag, uint seed = 0) inline size_t qHash(QCborSimpleType tag, size_t seed = 0)
{ {
return qHash(quint8(tag), seed); return qHash(quint8(tag), seed);
} }
inline uint qHash(QCborTag tag, uint seed = 0) inline size_t qHash(QCborTag tag, size_t seed = 0)
{ {
return qHash(quint64(tag), seed); return qHash(quint64(tag), seed);
} }

View File

@ -1744,7 +1744,7 @@ void QCborMap::detach(qsizetype reserved)
\sa operator+=(), operator-() \sa operator+=(), operator-()
*/ */
uint qHash(const QCborMap &map, uint seed) size_t qHash(const QCborMap &map, size_t seed)
{ {
return qHashRange(map.begin(), map.end(), seed); return qHashRange(map.begin(), map.end(), seed);
} }

View File

@ -350,7 +350,7 @@ inline QCborMap QCborValueRef::toMap(const QCborMap &m) const
return concrete().toMap(m); return concrete().toMap(m);
} }
Q_CORE_EXPORT uint qHash(const QCborMap &map, uint seed = 0); Q_CORE_EXPORT size_t qHash(const QCborMap &map, size_t seed = 0);
#if !defined(QT_NO_DEBUG_STREAM) #if !defined(QT_NO_DEBUG_STREAM)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborMap &m); Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborMap &m);

View File

@ -2921,7 +2921,7 @@ inline QCborMap::QCborMap(QCborContainerPrivate &dd) noexcept
{ {
} }
uint qHash(const QCborValue &value, uint seed) size_t qHash(const QCborValue &value, size_t seed)
{ {
switch (value.type()) { switch (value.type()) {
case QCborValue::Integer: case QCborValue::Integer:

View File

@ -481,7 +481,7 @@ private:
qsizetype i; qsizetype i;
}; };
Q_CORE_EXPORT uint qHash(const QCborValue &value, uint seed = 0); Q_CORE_EXPORT size_t qHash(const QCborValue &value, size_t seed = 0);
#if !defined(QT_NO_DEBUG_STREAM) #if !defined(QT_NO_DEBUG_STREAM)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborValue &v); Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborValue &v);

View File

@ -1133,7 +1133,7 @@ void QJsonArray::compact()
a->compact(a->elements.size()); a->compact(a->elements.size());
} }
uint qHash(const QJsonArray &array, uint seed) size_t qHash(const QJsonArray &array, size_t seed)
{ {
return qHashRange(array.begin(), array.end(), seed); return qHashRange(array.begin(), array.end(), seed);
} }

View File

@ -252,7 +252,7 @@ private:
Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QJsonArray) Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QJsonArray)
Q_CORE_EXPORT uint qHash(const QJsonArray &array, uint seed = 0); Q_CORE_EXPORT size_t qHash(const QJsonArray &array, size_t seed = 0);
#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY) #if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonArray &); Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonArray &);

View File

@ -1487,7 +1487,7 @@ void QJsonObject::removeAt(int index)
o->removeAt(index); o->removeAt(index);
} }
uint qHash(const QJsonObject &object, uint seed) size_t qHash(const QJsonObject &object, size_t seed)
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;
for (auto it = object.begin(), end = object.end(); it != end; ++it) { for (auto it = object.begin(), end = object.end(); it != end; ++it) {

View File

@ -302,7 +302,7 @@ private:
Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QJsonObject) Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QJsonObject)
Q_CORE_EXPORT uint qHash(const QJsonObject &object, uint seed = 0); Q_CORE_EXPORT size_t qHash(const QJsonObject &object, size_t seed = 0);
#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY) #if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonObject &); Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonObject &);

View File

@ -943,7 +943,7 @@ QJsonValue QJsonValueRef::toValue() const
return o->valueAt(index); return o->valueAt(index);
} }
uint qHash(const QJsonValue &value, uint seed) size_t qHash(const QJsonValue &value, size_t seed)
{ {
switch (value.type()) { switch (value.type()) {
case QJsonValue::Null: case QJsonValue::Null:

View File

@ -232,7 +232,7 @@ public:
Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QJsonValue) Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QJsonValue)
Q_CORE_EXPORT uint qHash(const QJsonValue &value, uint seed = 0); Q_CORE_EXPORT size_t qHash(const QJsonValue &value, size_t seed = 0);
#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY) #if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonValue &); Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonValue &);

View File

@ -216,12 +216,9 @@ public:
QPointer<QObject> guard; QPointer<QObject> guard;
QObject *obj; QObject *obj;
QByteArray prop; QByteArray prop;
// two overloads because friends can't have default arguments friend size_t qHash(const RestorableId &key, size_t seed)
friend uint qHash(const RestorableId &key, uint seed)
noexcept(noexcept(qHash(std::declval<QByteArray>()))) noexcept(noexcept(qHash(std::declval<QByteArray>())))
{ return qHash(qMakePair(key.obj, key.prop), seed); } { return qHash(qMakePair(key.obj, key.prop), seed); }
friend uint qHash(const RestorableId &key) noexcept(noexcept(qHash(key, 0U)))
{ return qHash(key, 0U); }
friend bool operator==(const RestorableId &lhs, const RestorableId &rhs) noexcept friend bool operator==(const RestorableId &lhs, const RestorableId &rhs) noexcept
{ return lhs.obj == rhs.obj && lhs.prop == rhs.prop; } { return lhs.obj == rhs.obj && lhs.prop == rhs.prop; }
friend bool operator!=(const RestorableId &lhs, const RestorableId &rhs) noexcept friend bool operator!=(const RestorableId &lhs, const RestorableId &rhs) noexcept

View File

@ -5028,7 +5028,7 @@ QByteArray QByteArray::toPercentEncoding(const QByteArray &exclude, const QByteA
Returns the hash value for \a key, using Returns the hash value for \a key, using
\a seed to seed the calculation. \a seed to seed the calculation.
*/ */
uint qHash(const QByteArray::FromBase64Result &key, uint seed) noexcept size_t qHash(const QByteArray::FromBase64Result &key, size_t seed) noexcept
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;
seed = hash(seed, key.decoded); seed = hash(seed, key.decoded);

View File

@ -697,7 +697,7 @@ inline bool operator!=(const QByteArray::FromBase64Result &lhs, const QByteArray
return !operator==(lhs, rhs); return !operator==(lhs, rhs);
} }
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QByteArray::FromBase64Result &key, uint seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QByteArray::FromBase64Result &key, size_t seed = 0) noexcept;
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -1089,7 +1089,7 @@ bool QLocale::operator!=(const QLocale &other) const
Returns the hash value for \a key, using Returns the hash value for \a key, using
\a seed to seed the calculation. \a seed to seed the calculation.
*/ */
uint qHash(const QLocale &key, uint seed) noexcept size_t qHash(const QLocale &key, size_t seed) noexcept
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;
seed = hash(seed, key.d->m_data); seed = hash(seed, key.d->m_data);

View File

@ -59,7 +59,7 @@ class QTextStreamPrivate;
class QLocalePrivate; class QLocalePrivate;
Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed = 0) noexcept; Q_CORE_EXPORT size_t qHash(const QLocale &key, size_t seed = 0) noexcept;
class Q_CORE_EXPORT QLocale class Q_CORE_EXPORT QLocale
{ {
@ -1131,7 +1131,7 @@ private:
friend class QSystemLocale; friend class QSystemLocale;
friend class QCalendarBackend; friend class QCalendarBackend;
friend class QGregorianCalendar; friend class QGregorianCalendar;
friend Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed) noexcept; friend Q_CORE_EXPORT size_t qHash(const QLocale &key, size_t seed) noexcept;
QSharedDataPointer<QLocalePrivate> d; QSharedDataPointer<QLocalePrivate> d;
}; };

View File

@ -891,7 +891,7 @@ static bool operator==(const QRegExpEngineKey &key1, const QRegExpEngineKey &key
&& key1.cs == key2.cs; && key1.cs == key2.cs;
} }
static uint qHash(const QRegExpEngineKey &key, uint seed = 0) noexcept static size_t qHash(const QRegExpEngineKey &key, size_t seed = 0) noexcept
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;
seed = hash(seed, key.pattern); seed = hash(seed, key.pattern);
@ -4041,7 +4041,7 @@ bool QRegExp::operator==(const QRegExp &rx) const
Returns the hash value for \a key, using Returns the hash value for \a key, using
\a seed to seed the calculation. \a seed to seed the calculation.
*/ */
uint qHash(const QRegExp &key, uint seed) noexcept size_t qHash(const QRegExp &key, size_t seed) noexcept
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;
seed = hash(seed, key.priv->engineKey); seed = hash(seed, key.priv->engineKey);

View File

@ -53,7 +53,7 @@ struct QRegExpPrivate;
class QStringList; class QStringList;
class QRegExp; class QRegExp;
Q_CORE_EXPORT uint qHash(const QRegExp &key, uint seed = 0) noexcept; Q_CORE_EXPORT size_t qHash(const QRegExp &key, size_t seed = 0) noexcept;
class Q_CORE_EXPORT QRegExp class Q_CORE_EXPORT QRegExp
{ {
@ -110,7 +110,7 @@ public:
static QString escape(const QString &str); static QString escape(const QString &str);
friend Q_CORE_EXPORT uint qHash(const QRegExp &key, uint seed) noexcept; friend Q_CORE_EXPORT size_t qHash(const QRegExp &key, size_t seed) noexcept;
private: private:
QRegExpPrivate *priv; QRegExpPrivate *priv;

View File

@ -1828,7 +1828,7 @@ bool QRegularExpression::operator==(const QRegularExpression &re) const
Returns the hash value for \a key, using Returns the hash value for \a key, using
\a seed to seed the calculation. \a seed to seed the calculation.
*/ */
uint qHash(const QRegularExpression &key, uint seed) noexcept size_t qHash(const QRegularExpression &key, size_t seed) noexcept
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;
seed = hash(seed, key.d->pattern); seed = hash(seed, key.d->pattern);

View File

@ -59,7 +59,7 @@ class QRegularExpressionMatchIterator;
struct QRegularExpressionPrivate; struct QRegularExpressionPrivate;
class QRegularExpression; class QRegularExpression;
Q_CORE_EXPORT uint qHash(const QRegularExpression &key, uint seed = 0) noexcept; Q_CORE_EXPORT size_t qHash(const QRegularExpression &key, size_t seed = 0) noexcept;
class Q_CORE_EXPORT QRegularExpression class Q_CORE_EXPORT QRegularExpression
{ {
@ -167,7 +167,7 @@ private:
friend class QRegularExpressionMatch; friend class QRegularExpressionMatch;
friend struct QRegularExpressionMatchPrivate; friend struct QRegularExpressionMatchPrivate;
friend class QRegularExpressionMatchIterator; friend class QRegularExpressionMatchIterator;
friend Q_CORE_EXPORT uint qHash(const QRegularExpression &key, uint seed) noexcept; friend Q_CORE_EXPORT size_t qHash(const QRegularExpression &key, size_t seed) noexcept;
QRegularExpression(QRegularExpressionPrivate &dd); QRegularExpression(QRegularExpressionPrivate &dd);
QExplicitlySharedDataPointer<QRegularExpressionPrivate> d; QExplicitlySharedDataPointer<QRegularExpressionPrivate> d;

View File

@ -61,7 +61,7 @@ inline bool operator==(const CalendarName &u, const CalendarName &v)
return u.compare(v, Qt::CaseInsensitive) == 0; return u.compare(v, Qt::CaseInsensitive) == 0;
} }
inline uint qHash(const CalendarName &key, uint seed = 0) noexcept inline size_t qHash(const CalendarName &key, size_t seed = 0) noexcept
{ {
return qHash(key.toLower(), seed); return qHash(key.toLower(), seed);
} }

View File

@ -5950,13 +5950,13 @@ QDebug operator<<(QDebug dbg, const QDateTime &date)
} }
#endif // debug_stream && datestring #endif // debug_stream && datestring
/*! \fn uint qHash(const QDateTime &key, uint seed = 0) /*! \fn size_t qHash(const QDateTime &key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
uint qHash(const QDateTime &key, uint seed) size_t qHash(const QDateTime &key, size_t seed)
{ {
// Use to toMSecsSinceEpoch instead of individual qHash functions for // Use to toMSecsSinceEpoch instead of individual qHash functions for
// QDate/QTime/spec/offset because QDateTime::operator== converts both arguments // QDate/QTime/spec/offset because QDateTime::operator== converts both arguments
@ -5965,24 +5965,24 @@ uint qHash(const QDateTime &key, uint seed)
return key.isValid() ? qHash(key.toMSecsSinceEpoch(), seed) : seed; return key.isValid() ? qHash(key.toMSecsSinceEpoch(), seed) : seed;
} }
/*! \fn uint qHash(QDate key, uint seed = 0) /*! \fn size_t qHash(QDate key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
uint qHash(QDate key, uint seed) noexcept size_t qHash(QDate key, size_t seed) noexcept
{ {
return qHash(key.toJulianDay(), seed); return qHash(key.toJulianDay(), seed);
} }
/*! \fn uint qHash(QTime key, uint seed = 0) /*! \fn size_t qHash(QTime key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
uint qHash(QTime key, uint seed) noexcept size_t qHash(QTime key, size_t seed) noexcept
{ {
return qHash(key.msecsSinceStartOfDay(), seed); return qHash(key.msecsSinceStartOfDay(), seed);
} }

View File

@ -447,9 +447,9 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QDateTime &);
// QDateTime is not noexcept for now -- to be revised once // QDateTime is not noexcept for now -- to be revised once
// timezone and calendaring support is added // timezone and calendaring support is added
Q_CORE_EXPORT uint qHash(const QDateTime &key, uint seed = 0); Q_CORE_EXPORT size_t qHash(const QDateTime &key, size_t seed = 0);
Q_CORE_EXPORT uint qHash(QDate key, uint seed = 0) noexcept; Q_CORE_EXPORT size_t qHash(QDate key, size_t seed = 0) noexcept;
Q_CORE_EXPORT uint qHash(QTime key, uint seed = 0) noexcept; Q_CORE_EXPORT size_t qHash(QTime key, size_t seed = 0) noexcept;
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -50,7 +50,7 @@ class Q_CORE_EXPORT QBitArray
{ {
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QBitArray &); friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QBitArray &);
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QBitArray &); friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QBitArray &);
friend Q_CORE_EXPORT uint qHash(const QBitArray &key, uint seed) noexcept; friend Q_CORE_EXPORT size_t qHash(const QBitArray &key, size_t seed) noexcept;
QByteArray d; QByteArray d;
public: public:

View File

@ -210,11 +210,6 @@ static inline uint hash(const uchar *p, size_t len, uint seed) noexcept
return h; return h;
} }
uint qHashBits(const void *p, size_t len, uint seed) noexcept
{
return hash(static_cast<const uchar*>(p), int(len), seed);
}
static inline uint hash(const QChar *p, size_t len, uint seed) noexcept static inline uint hash(const QChar *p, size_t len, uint seed) noexcept
{ {
uint h = seed; uint h = seed;
@ -228,33 +223,38 @@ static inline uint hash(const QChar *p, size_t len, uint seed) noexcept
return h; return h;
} }
uint qHash(const QByteArray &key, uint seed) noexcept size_t qHashBits(const void *p, size_t size, size_t seed) noexcept
{
return hash(static_cast<const uchar*>(p), int(size), static_cast<uint>(seed));
}
size_t qHash(const QByteArray &key, size_t seed) noexcept
{ {
return hash(reinterpret_cast<const uchar *>(key.constData()), size_t(key.size()), seed); return hash(reinterpret_cast<const uchar *>(key.constData()), size_t(key.size()), seed);
} }
#if QT_STRINGVIEW_LEVEL < 2 #if QT_STRINGVIEW_LEVEL < 2
uint qHash(const QString &key, uint seed) noexcept size_t qHash(const QString &key, size_t seed) noexcept
{ {
return hash(key.unicode(), size_t(key.size()), seed); return hash(key.unicode(), size_t(key.size()), seed);
} }
uint qHash(const QStringRef &key, uint seed) noexcept size_t qHash(const QStringRef &key, size_t seed) noexcept
{ {
return hash(key.unicode(), size_t(key.size()), seed); return hash(key.unicode(), size_t(key.size()), seed);
} }
#endif #endif
uint qHash(QStringView key, uint seed) noexcept size_t qHash(QStringView key, size_t seed) noexcept
{ {
return hash(key.data(), key.size(), seed); return hash(key.data(), key.size(), seed);
} }
uint qHash(const QBitArray &bitArray, uint seed) noexcept size_t qHash(const QBitArray &bitArray, size_t seed) noexcept
{ {
int m = bitArray.d.size() - 1; int m = bitArray.d.size() - 1;
uint result = hash(reinterpret_cast<const uchar *>(bitArray.d.constData()), size_t result = qHashBits(reinterpret_cast<const uchar *>(bitArray.d.constData()), size_t(qMax(0, m)), seed);
size_t(qMax(0, m)), seed);
// deal with the last 0 to 7 bits manually, because we can't trust that // deal with the last 0 to 7 bits manually, because we can't trust that
// the padding is initialized to 0 in bitArray.d // the padding is initialized to 0 in bitArray.d
@ -264,7 +264,7 @@ uint qHash(const QBitArray &bitArray, uint seed) noexcept
return result; return result;
} }
uint qHash(QLatin1String key, uint seed) noexcept size_t qHash(QLatin1String key, size_t seed) noexcept
{ {
return hash(reinterpret_cast<const uchar *>(key.data()), size_t(key.size()), seed); return hash(reinterpret_cast<const uchar *>(key.data()), size_t(key.size()), seed);
} }
@ -406,7 +406,7 @@ uint qt_hash(QStringView key, uint chained) noexcept
} }
/*! /*!
\fn template <typename T1, typename T2> uint qHash(const QPair<T1, T2> &key, uint seed = 0) \fn template <typename T1, typename T2> size_t qHash(const QPair<T1, T2> &key, size_t seed = 0)
\since 5.0 \since 5.0
\relates QHash \relates QHash
@ -416,7 +416,7 @@ uint qt_hash(QStringView key, uint chained) noexcept
*/ */
/*! /*!
\fn template <typename T1, typename T2> uint qHash(const std::pair<T1, T2> &key, uint seed = 0) \fn template <typename T1, typename T2> size_t qHash(const std::pair<T1, T2> &key, size_t seed = 0)
\since 5.7 \since 5.7
\relates QHash \relates QHash
@ -430,7 +430,7 @@ uint qt_hash(QStringView key, uint chained) noexcept
constraints, we cannot change the QPair algorithm to match the std::pair one before Qt 6. constraints, we cannot change the QPair algorithm to match the std::pair one before Qt 6.
*/ */
/*! \fn template <typename InputIterator> uint qHashRange(InputIterator first, InputIterator last, uint seed = 0) /*! \fn template <typename InputIterator> size_t qHashRange(InputIterator first, InputIterator last, size_t seed = 0)
\relates QHash \relates QHash
\since 5.5 \since 5.5
@ -465,7 +465,7 @@ uint qt_hash(QStringView key, uint chained) noexcept
\sa qHashBits(), qHashRangeCommutative() \sa qHashBits(), qHashRangeCommutative()
*/ */
/*! \fn template <typename InputIterator> uint qHashRangeCommutative(InputIterator first, InputIterator last, uint seed = 0) /*! \fn template <typename InputIterator> size_t qHashRangeCommutative(InputIterator first, InputIterator last, size_t seed = 0)
\relates QHash \relates QHash
\since 5.5 \since 5.5
@ -501,7 +501,7 @@ uint qt_hash(QStringView key, uint chained) noexcept
\sa qHashBits(), qHashRange() \sa qHashBits(), qHashRange()
*/ */
/*! \fn uint qHashBits(const void *p, size_t len, uint seed = 0) /*! \fn size_t qHashBits(const void *p, size_t len, size_t seed = 0)
\relates QHash \relates QHash
\since 5.4 \since 5.4
@ -526,77 +526,77 @@ uint qt_hash(QStringView key, uint chained) noexcept
\sa qHashRange(), qHashRangeCommutative() \sa qHashRange(), qHashRangeCommutative()
*/ */
/*! \fn uint qHash(char key, uint seed = 0) /*! \fn size_t qHash(char key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(uchar key, uint seed = 0) /*! \fn size_t qHash(uchar key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(signed char key, uint seed = 0) /*! \fn size_t qHash(signed char key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(ushort key, uint seed = 0) /*! \fn size_t qHash(ushort key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(short key, uint seed = 0) /*! \fn size_t qHash(short key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(uint key, uint seed = 0) /*! \fn size_t qHash(uint key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(int key, uint seed = 0) /*! \fn size_t qHash(int key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(ulong key, uint seed = 0) /*! \fn size_t qHash(ulong key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(long key, uint seed = 0) /*! \fn size_t qHash(long key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(quint64 key, uint seed = 0) /*! \fn size_t qHash(quint64 key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(qint64 key, uint seed = 0) /*! \fn size_t qHash(qint64 key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
@ -608,7 +608,7 @@ uint qt_hash(QStringView key, uint chained) noexcept
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
uint qHash(float key, uint seed) noexcept size_t qHash(float key, size_t seed) noexcept
{ {
return key != 0.0f ? hash(reinterpret_cast<const uchar *>(&key), sizeof(key), seed) : seed ; return key != 0.0f ? hash(reinterpret_cast<const uchar *>(&key), sizeof(key), seed) : seed ;
} }
@ -618,7 +618,7 @@ uint qHash(float key, uint seed) noexcept
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
uint qHash(double key, uint seed) noexcept size_t qHash(double key, size_t seed) noexcept
{ {
return key != 0.0 ? hash(reinterpret_cast<const uchar *>(&key), sizeof(key), seed) : seed ; return key != 0.0 ? hash(reinterpret_cast<const uchar *>(&key), sizeof(key), seed) : seed ;
} }
@ -629,62 +629,62 @@ uint qHash(double key, uint seed) noexcept
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
uint qHash(long double key, uint seed) noexcept size_t qHash(long double key, size_t seed) noexcept
{ {
return key != 0.0L ? hash(reinterpret_cast<const uchar *>(&key), sizeof(key), seed) : seed ; return key != 0.0L ? hash(reinterpret_cast<const uchar *>(&key), sizeof(key), seed) : seed ;
} }
#endif #endif
/*! \fn uint qHash(const QChar key, uint seed = 0) /*! \fn size_t qHash(const QChar key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(const QByteArray &key, uint seed = 0) /*! \fn size_t qHash(const QByteArray &key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(const QBitArray &key, uint seed = 0) /*! \fn size_t qHash(const QBitArray &key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(const QString &key, uint seed = 0) /*! \fn size_t qHash(const QString &key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(const QStringRef &key, uint seed = 0) /*! \fn size_t qHash(const QStringRef &key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(QStringView key, uint seed = 0) /*! \fn size_t qHash(QStringView key, size_t seed = 0)
\relates QStringView \relates QStringView
\since 5.10 \since 5.10
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn uint qHash(QLatin1String key, uint seed = 0) /*! \fn size_t qHash(QLatin1String key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn template <class T> uint qHash(const T *key, uint seed = 0) /*! \fn template <class T> size_t qHash(const T *key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0
@ -2855,7 +2855,7 @@ uint qHash(long double key, uint seed) noexcept
*/ */
/*! /*!
\fn template <class Key, class T> uint qHash(const QHash<Key, T> &key, uint seed = 0) \fn template <class Key, class T> size_t qHash(const QHash<Key, T> &key, size_t seed = 0)
\since 5.8 \since 5.8
\relates QHash \relates QHash
@ -2865,7 +2865,7 @@ uint qHash(long double key, uint seed) noexcept
*/ */
/*! /*!
\fn template <class Key, class T> uint qHash(const QMultiHash<Key, T> &key, uint seed = 0) \fn template <class Key, class T> size_t qHash(const QMultiHash<Key, T> &key, size_t seed = 0)
\since 5.8 \since 5.8
\relates QMultiHash \relates QMultiHash

View File

@ -2011,7 +2011,7 @@ public:
#endif // !QT_NO_JAVA_STYLE_ITERATORS #endif // !QT_NO_JAVA_STYLE_ITERATORS
template <class Key, class T> template <class Key, class T>
uint qHash(const QHash<Key, T> &key, uint seed = 0) size_t qHash(const QHash<Key, T> &key, size_t seed = 0)
noexcept(noexcept(qHash(std::declval<Key&>())) && noexcept(qHash(std::declval<T&>()))) noexcept(noexcept(qHash(std::declval<Key&>())) && noexcept(qHash(std::declval<T&>())))
{ {
QtPrivate::QHashCombineCommutative hash; QtPrivate::QHashCombineCommutative hash;
@ -2024,7 +2024,7 @@ uint qHash(const QHash<Key, T> &key, uint seed = 0)
} }
template <class Key, class T> template <class Key, class T>
inline uint qHash(const QMultiHash<Key, T> &key, uint seed = 0) inline size_t qHash(const QMultiHash<Key, T> &key, size_t seed = 0)
noexcept(noexcept(qHash(std::declval<Key&>())) && noexcept(qHash(std::declval<T&>()))) noexcept(noexcept(qHash(std::declval<Key&>())) && noexcept(qHash(std::declval<T&>())))
{ {
const QHash<Key, T> &key2 = key; const QHash<Key, T> &key2 = key;

View File

@ -70,7 +70,7 @@ Q_CORE_EXPORT void qSetGlobalQHashSeed(int newSeed);
namespace QHashPrivate { namespace QHashPrivate {
Q_DECL_CONST_FUNCTION constexpr uint hash(size_t key, uint seed) noexcept Q_DECL_CONST_FUNCTION constexpr size_t hash(size_t key, size_t seed) noexcept
{ {
key ^= seed; key ^= seed;
if constexpr (sizeof(size_t) == 4) { if constexpr (sizeof(size_t) == 4) {
@ -86,74 +86,74 @@ Q_DECL_CONST_FUNCTION constexpr uint hash(size_t key, uint seed) noexcept
key ^= key >> 32; key ^= key >> 32;
key *= UINT64_C(0xd6e8feb86659fd93); key *= UINT64_C(0xd6e8feb86659fd93);
key ^= key >> 32; key ^= key >> 32;
return uint(key); return key;
} }
} }
} }
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHashBits(const void *p, size_t size, uint seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHashBits(const void *p, size_t size, size_t seed = 0) noexcept;
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(char key, uint seed = 0) noexcept Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(char key, size_t seed = 0) noexcept
{ return QHashPrivate::hash(size_t(key), seed); } { return QHashPrivate::hash(size_t(key), seed); }
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uchar key, uint seed = 0) noexcept Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(uchar key, size_t seed = 0) noexcept
{ return QHashPrivate::hash(size_t(key), seed); } { return QHashPrivate::hash(size_t(key), seed); }
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(signed char key, uint seed = 0) noexcept Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(signed char key, size_t seed = 0) noexcept
{ return QHashPrivate::hash(size_t(key), seed); } { return QHashPrivate::hash(size_t(key), seed); }
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ushort key, uint seed = 0) noexcept Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(ushort key, size_t seed = 0) noexcept
{ return QHashPrivate::hash(size_t(key), seed); } { return QHashPrivate::hash(size_t(key), seed); }
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(short key, uint seed = 0) noexcept Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(short key, size_t seed = 0) noexcept
{ return QHashPrivate::hash(size_t(key), seed); } { return QHashPrivate::hash(size_t(key), seed); }
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uint key, uint seed = 0) noexcept Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(uint key, size_t seed = 0) noexcept
{ return QHashPrivate::hash(size_t(key), seed); } { return QHashPrivate::hash(size_t(key), seed); }
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(int key, uint seed = 0) noexcept Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(int key, size_t seed = 0) noexcept
{ return QHashPrivate::hash(size_t(key), seed); } { return QHashPrivate::hash(size_t(key), seed); }
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ulong key, uint seed = 0) noexcept Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(ulong key, size_t seed = 0) noexcept
{ return QHashPrivate::hash(size_t(key), seed); } { return QHashPrivate::hash(size_t(key), seed); }
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(long key, uint seed = 0) noexcept Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(long key, size_t seed = 0) noexcept
{ return QHashPrivate::hash(size_t(key), seed); } { return QHashPrivate::hash(size_t(key), seed); }
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(quint64 key, uint seed = 0) noexcept Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(quint64 key, size_t seed = 0) noexcept
{ {
if (sizeof(quint64) > sizeof(size_t)) if (sizeof(quint64) > sizeof(size_t))
key ^= (key >> 32); key ^= (key >> 32);
return QHashPrivate::hash(size_t(key), seed); return QHashPrivate::hash(size_t(key), seed);
} }
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(qint64 key, uint seed = 0) noexcept { return qHash(quint64(key), seed); } Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(qint64 key, size_t seed = 0) noexcept { return qHash(quint64(key), seed); }
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(float key, uint seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_CONST_FUNCTION size_t qHash(float key, size_t seed = 0) noexcept;
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(double key, uint seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_CONST_FUNCTION size_t qHash(double key, size_t seed = 0) noexcept;
#if !defined(Q_OS_DARWIN) || defined(Q_CLANG_QDOC) #if !defined(Q_OS_DARWIN) || defined(Q_CLANG_QDOC)
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(long double key, uint seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_CONST_FUNCTION size_t qHash(long double key, size_t seed = 0) noexcept;
#endif #endif
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(const QChar key, uint seed = 0) noexcept { return qHash(key.unicode(), seed); } Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(const QChar key, size_t seed = 0) noexcept { return qHash(key.unicode(), seed); }
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QByteArray &key, uint seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QByteArray &key, size_t seed = 0) noexcept;
#if QT_STRINGVIEW_LEVEL < 2 #if QT_STRINGVIEW_LEVEL < 2
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QString &key, uint seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QString &key, size_t seed = 0) noexcept;
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QStringRef &key, uint seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QStringRef &key, size_t seed = 0) noexcept;
#endif #endif
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QStringView key, uint seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QStringView key, size_t seed = 0) noexcept;
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QBitArray &key, uint seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QBitArray &key, size_t seed = 0) noexcept;
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QLatin1String key, uint seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QLatin1String key, size_t seed = 0) noexcept;
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(QStringView key, uint chained = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(QStringView key, uint chained = 0) noexcept;
Q_DECL_CONST_FUNCTION inline uint qHash(std::nullptr_t, uint seed = 0) noexcept Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(std::nullptr_t, size_t seed = 0) noexcept
{ {
return qHash(reinterpret_cast<quintptr>(nullptr), seed); return seed;
} }
template <class T> inline uint qHash(const T *key, uint seed = 0) noexcept template <class T> inline size_t qHash(const T *key, size_t seed = 0) noexcept
{ {
return qHash(reinterpret_cast<quintptr>(key), seed); return qHash(reinterpret_cast<quintptr>(key), seed);
} }
template<typename T> inline uint qHash(const T &t, uint seed) template<typename T> inline size_t qHash(const T &t, size_t seed)
noexcept(noexcept(qHash(t))) noexcept(noexcept(qHash(t)))
{ return qHash(t) ^ seed; } { return qHash(t) ^ seed; }
namespace QtPrivate { namespace QtPrivate {
struct QHashCombine { struct QHashCombine {
typedef uint result_type; typedef size_t result_type;
template <typename T> template <typename T>
Q_DECL_CONSTEXPR result_type operator()(uint seed, const T &t) const noexcept(noexcept(qHash(t))) constexpr result_type operator()(size_t seed, const T &t) const noexcept(noexcept(qHash(t)))
// combiner taken from N3876 / boost::hash_combine // combiner taken from N3876 / boost::hash_combine
{ return seed ^ (qHash(t) + 0x9e3779b9 + (seed << 6) + (seed >> 2)) ; } { return seed ^ (qHash(t) + 0x9e3779b9 + (seed << 6) + (seed >> 2)) ; }
}; };
@ -164,37 +164,38 @@ struct QHashCombineCommutative {
// usually what we want: {0,1,3} should hash differently than // usually what we want: {0,1,3} should hash differently than
// {1,3,0}. Except when it isn't (e.g. for QSet and // {1,3,0}. Except when it isn't (e.g. for QSet and
// QHash). Therefore, provide a commutative combiner, too. // QHash). Therefore, provide a commutative combiner, too.
typedef uint result_type; typedef size_t result_type;
template <typename T> template <typename T>
Q_DECL_CONSTEXPR result_type operator()(uint seed, const T &t) const noexcept(noexcept(qHash(t))) constexpr result_type operator()(size_t seed, const T &t) const noexcept(noexcept(qHash(t)))
{ return seed + qHash(t); } // don't use xor! { return seed + qHash(t); } // don't use xor!
}; };
} // namespace QtPrivate } // namespace QtPrivate
template <typename InputIterator> template <typename InputIterator>
inline uint qHashRange(InputIterator first, InputIterator last, uint seed = 0) inline size_t qHashRange(InputIterator first, InputIterator last, size_t seed = 0)
noexcept(noexcept(qHash(*first))) // assume iterator operations don't throw noexcept(noexcept(qHash(*first))) // assume iterator operations don't throw
{ {
return std::accumulate(first, last, seed, QtPrivate::QHashCombine()); return std::accumulate(first, last, seed, QtPrivate::QHashCombine());
} }
template <typename InputIterator> template <typename InputIterator>
inline uint qHashRangeCommutative(InputIterator first, InputIterator last, uint seed = 0) inline size_t qHashRangeCommutative(InputIterator first, InputIterator last, size_t seed = 0)
noexcept(noexcept(qHash(*first))) // assume iterator operations don't throw noexcept(noexcept(qHash(*first))) // assume iterator operations don't throw
{ {
return std::accumulate(first, last, seed, QtPrivate::QHashCombineCommutative()); return std::accumulate(first, last, seed, QtPrivate::QHashCombineCommutative());
} }
template <typename T1, typename T2> inline uint qHash(const QPair<T1, T2> &key, uint seed = 0) template <typename T1, typename T2> inline size_t qHash(const QPair<T1, T2> &key, size_t seed = 0)
noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed)))
{ {
uint h1 = qHash(key.first, seed); QtPrivate::QHashCombine hash;
uint h2 = qHash(key.second, seed); seed = hash(seed, key.first);
return ((h1 << 16) | (h1 >> 16)) ^ h2 ^ seed; seed = hash(seed, key.second);
return seed;
} }
template <typename T1, typename T2> inline uint qHash(const std::pair<T1, T2> &key, uint seed = 0) template <typename T1, typename T2> inline size_t qHash(const std::pair<T1, T2> &key, size_t seed = 0)
noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed)))
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;

View File

@ -230,7 +230,7 @@ QSet(InputIterator, InputIterator) -> QSet<ValueType>;
#endif #endif
template <typename T> template <typename T>
uint qHash(const QSet<T> &key, uint seed = 0) size_t qHash(const QSet<T> &key, size_t seed = 0)
noexcept(noexcept(qHashRangeCommutative(key.begin(), key.end(), seed))) noexcept(noexcept(qHashRangeCommutative(key.begin(), key.end(), seed)))
{ {
return qHashRangeCommutative(key.begin(), key.end(), seed); return qHashRangeCommutative(key.begin(), key.end(), seed);

View File

@ -1136,7 +1136,7 @@
*/ */
/*! /*!
\fn template <class T> uint qHash(const QSet<T> &key, uint seed = 0) \fn template <class T> size_t qHash(const QSet<T> &key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.5 \since 5.5

View File

@ -305,12 +305,12 @@ Q_INLINE_TEMPLATE void swap(QExplicitlySharedDataPointer<T> &p1, QExplicitlyShar
{ p1.swap(p2); } { p1.swap(p2); }
template <class T> template <class T>
Q_INLINE_TEMPLATE uint qHash(const QSharedDataPointer<T> &ptr, uint seed = 0) noexcept Q_INLINE_TEMPLATE size_t qHash(const QSharedDataPointer<T> &ptr, size_t seed = 0) noexcept
{ {
return qHash(ptr.data(), seed); return qHash(ptr.data(), seed);
} }
template <class T> template <class T>
Q_INLINE_TEMPLATE uint qHash(const QExplicitlySharedDataPointer<T> &ptr, uint seed = 0) noexcept Q_INLINE_TEMPLATE size_t qHash(const QExplicitlySharedDataPointer<T> &ptr, size_t seed = 0) noexcept
{ {
return qHash(ptr.data(), seed); return qHash(ptr.data(), seed);
} }

View File

@ -882,7 +882,7 @@ Q_INLINE_TEMPLATE bool operator<(T *ptr1, const QSharedPointer<X> &ptr2)
// qHash // qHash
// //
template <class T> template <class T>
Q_INLINE_TEMPLATE uint qHash(const QSharedPointer<T> &ptr, uint seed = 0) Q_INLINE_TEMPLATE size_t qHash(const QSharedPointer<T> &ptr, size_t seed = 0)
{ {
return QT_PREPEND_NAMESPACE(qHash)(ptr.data(), seed); return QT_PREPEND_NAMESPACE(qHash)(ptr.data(), seed);
} }

View File

@ -611,7 +611,7 @@ inline bool operator>=(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengt
} }
template <typename T, qsizetype Prealloc> template <typename T, qsizetype Prealloc>
uint qHash(const QVarLengthArray<T, Prealloc> &key, uint seed = 0) size_t qHash(const QVarLengthArray<T, Prealloc> &key, size_t seed = 0)
noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed))) noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))
{ {
return qHashRange(key.cbegin(), key.cend(), seed); return qHashRange(key.cbegin(), key.cend(), seed);

View File

@ -903,7 +903,7 @@
*/ */
/*! /*!
\fn template <typename T, qsizetype Prealloc> uint qHash(const QVarLengthArray<T, Prealloc> &key, uint seed = 0) \fn template <typename T, qsizetype Prealloc> size_t qHash(const QVarLengthArray<T, Prealloc> &key, size_t seed = 0)
\relates QVarLengthArray \relates QVarLengthArray
\since 5.14 \since 5.14

View File

@ -731,7 +731,7 @@ Q_DECLARE_SEQUENTIAL_ITERATOR(Vector)
Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(Vector) Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(Vector)
template <typename T> template <typename T>
uint qHash(const QVector<T> &key, uint seed = 0) size_t qHash(const QVector<T> &key, size_t seed = 0)
noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed))) noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))
{ {
return qHashRange(key.cbegin(), key.cend(), seed); return qHashRange(key.cbegin(), key.cend(), seed);

View File

@ -391,7 +391,7 @@
*/ */
/*! /*!
\fn template <typename T> uint qHash(const QVector<T> &key, uint seed = 0) \fn template <typename T> size_t qHash(const QVector<T> &key, size_t seed = 0)
\since 5.6 \since 5.6
\relates QVector \relates QVector

View File

@ -541,14 +541,14 @@ QDebug operator<<(QDebug debug, const QVersionNumber &version)
#endif #endif
/*! /*!
\fn uint qHash(const QVersionNumber &key, uint seed) \fn size_t qHash(const QVersionNumber &key, size_t seed)
\relates QHash \relates QHash
\since 5.6 \since 5.6
Returns the hash value for the \a key, using \a seed to seed the Returns the hash value for the \a key, using \a seed to seed the
calculation. calculation.
*/ */
uint qHash(const QVersionNumber &key, uint seed) size_t qHash(const QVersionNumber &key, size_t seed)
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;
for (int i = 0; i < key.segmentCount(); ++i) for (int i = 0; i < key.segmentCount(); ++i)

View File

@ -52,7 +52,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QVersionNumber; class QVersionNumber;
Q_CORE_EXPORT uint qHash(const QVersionNumber &key, uint seed = 0); Q_CORE_EXPORT size_t qHash(const QVersionNumber &key, size_t seed = 0);
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream& operator<<(QDataStream &out, const QVersionNumber &version); Q_CORE_EXPORT QDataStream& operator<<(QDataStream &out, const QVersionNumber &version);
@ -283,7 +283,7 @@ private:
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM
friend Q_CORE_EXPORT QDataStream& operator>>(QDataStream &in, QVersionNumber &version); friend Q_CORE_EXPORT QDataStream& operator>>(QDataStream &in, QVersionNumber &version);
#endif #endif
friend Q_CORE_EXPORT uint qHash(const QVersionNumber &key, uint seed); friend Q_CORE_EXPORT size_t qHash(const QVersionNumber &key, size_t seed);
}; };
Q_DECLARE_TYPEINFO(QVersionNumber, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QVersionNumber, Q_MOVABLE_TYPE);

View File

@ -105,7 +105,7 @@ inline bool operator!=(const QDBusObjectPath &lhs, const QDBusObjectPath &rhs)
inline bool operator<(const QDBusObjectPath &lhs, const QDBusObjectPath &rhs) inline bool operator<(const QDBusObjectPath &lhs, const QDBusObjectPath &rhs)
{ return lhs.path() < rhs.path(); } { return lhs.path() < rhs.path(); }
inline uint qHash(const QDBusObjectPath &objectPath, uint seed = 0) inline size_t qHash(const QDBusObjectPath &objectPath, size_t seed = 0)
{ return qHash(objectPath.path(), seed); } { return qHash(objectPath.path(), seed); }
@ -158,7 +158,7 @@ inline bool operator!=(const QDBusSignature &lhs, const QDBusSignature &rhs)
inline bool operator<(const QDBusSignature &lhs, const QDBusSignature &rhs) inline bool operator<(const QDBusSignature &lhs, const QDBusSignature &rhs)
{ return lhs.signature() < rhs.signature(); } { return lhs.signature() < rhs.signature(); }
inline uint qHash(const QDBusSignature &signature, uint seed = 0) inline size_t qHash(const QDBusSignature &signature, size_t seed = 0)
{ return qHash(signature.signature(), seed); } { return qHash(signature.signature(), seed); }
class QDBusVariant class QDBusVariant

View File

@ -253,9 +253,9 @@ QT_BEGIN_INCLUDE_NAMESPACE
#include "qpixmapcache.moc" #include "qpixmapcache.moc"
QT_END_INCLUDE_NAMESPACE QT_END_INCLUDE_NAMESPACE
uint qHash(const QPixmapCache::Key &k) size_t qHash(const QPixmapCache::Key &k, size_t seed)
{ {
return qHash(QPMCache::get(k)->key); return qHash(QPMCache::get(k)->key, seed);
} }
QPMCache::QPMCache() QPMCache::QPMCache()

View File

@ -59,7 +59,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
uint qHash(const QPixmapCache::Key &k); size_t qHash(const QPixmapCache::Key &k, size_t seed = 0);
class QPixmapCache::KeyData class QPixmapCache::KeyData
{ {

View File

@ -5231,7 +5231,7 @@ bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexce
Returns the hash value for \a key, using \a seed to seed the calculation. Returns the hash value for \a key, using \a seed to seed the calculation.
*/ */
uint qHash(QPointingDeviceUniqueId key, uint seed) noexcept size_t qHash(QPointingDeviceUniqueId key, size_t seed) noexcept
{ {
return qHash(key.numericId(), seed); return qHash(key.numericId(), seed);
} }

View File

@ -831,7 +831,7 @@ Q_DECLARE_TYPEINFO(QPointingDeviceUniqueId, Q_MOVABLE_TYPE);
Q_GUI_EXPORT bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept; Q_GUI_EXPORT bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept;
inline bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept inline bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept
{ return !operator==(lhs, rhs); } { return !operator==(lhs, rhs); }
Q_GUI_EXPORT uint qHash(QPointingDeviceUniqueId key, uint seed = 0) noexcept; Q_GUI_EXPORT size_t qHash(QPointingDeviceUniqueId key, size_t seed = 0) noexcept;

View File

@ -2749,9 +2749,9 @@ void QGuiApplicationPrivate::processContextMenuEvent(QWindowSystemInterfacePriva
} }
#endif #endif
Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k) Q_GUI_EXPORT size_t qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k, size_t seed)
{ {
return qHash(k.device) + k.touchPointId; return (qHash(k.device) + k.touchPointId) ^ seed;
} }
Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey &a, Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey &a,

View File

@ -372,7 +372,7 @@ private:
static qreal m_maxDevicePixelRatio; static qreal m_maxDevicePixelRatio;
}; };
Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k); Q_GUI_EXPORT size_t qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k, size_t seed = 0);
Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey &a, Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey &a,
const QGuiApplicationPrivate::ActiveTouchPointsKey &b); const QGuiApplicationPrivate::ActiveTouchPointsKey &b);

View File

@ -1467,7 +1467,7 @@ bool QKeySequence::operator==(const QKeySequence &other) const
Calculates the hash value of \a key, using Calculates the hash value of \a key, using
\a seed to seed the calculation. \a seed to seed the calculation.
*/ */
uint qHash(const QKeySequence &key, uint seed) noexcept size_t qHash(const QKeySequence &key, size_t seed) noexcept
{ {
return qHashRange(key.d->key, key.d->key + QKeySequencePrivate::MaxKeyCount, seed); return qHashRange(key.d->key, key.d->key + QKeySequencePrivate::MaxKeyCount, seed);
} }

View File

@ -65,7 +65,7 @@ void qt_set_sequence_auto_mnemonic(bool b);
class QVariant; class QVariant;
class QKeySequencePrivate; class QKeySequencePrivate;
Q_GUI_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QKeySequence &key, uint seed = 0) noexcept; Q_GUI_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QKeySequence &key, size_t seed = 0) noexcept;
class Q_GUI_EXPORT QKeySequence class Q_GUI_EXPORT QKeySequence
{ {
@ -211,7 +211,7 @@ private:
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks); friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks); friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks);
friend Q_GUI_EXPORT uint qHash(const QKeySequence &key, uint seed) noexcept; friend Q_GUI_EXPORT size_t qHash(const QKeySequence &key, size_t seed) noexcept;
friend class QShortcutMap; friend class QShortcutMap;
friend class QShortcut; friend class QShortcut;

View File

@ -133,9 +133,9 @@ inline bool operator!=(const QOpenGLConfig::Gpu &a, const QOpenGLConfig::Gpu &b)
return !a.equals(b); return !a.equals(b);
} }
inline uint qHash(const QOpenGLConfig::Gpu &gpu) inline size_t qHash(const QOpenGLConfig::Gpu &gpu, size_t seed = 0)
{ {
return qHash(gpu.vendorId) + qHash(gpu.deviceId) + qHash(gpu.driverVersion); return (qHash(gpu.vendorId) + qHash(gpu.deviceId) + qHash(gpu.driverVersion)) ^ seed;
} }
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -103,7 +103,7 @@ struct QOpenGLVersionStatus
OpenGLStatus status; OpenGLStatus status;
}; };
inline uint qHash(const QOpenGLVersionStatus &v, uint seed = 0) noexcept inline size_t qHash(const QOpenGLVersionStatus &v, size_t seed = 0) noexcept
{ {
return qHash(static_cast<int>(v.status * 1000) return qHash(static_cast<int>(v.status * 1000)
+ v.version.first * 100 + v.version.second * 10, seed); + v.version.first * 100 + v.version.second * 10, seed);

View File

@ -81,7 +81,7 @@ private:
QOpenGLVersionProfilePrivate* d; QOpenGLVersionProfilePrivate* d;
}; };
inline uint qHash(const QOpenGLVersionProfile &v, uint seed = 0) inline size_t qHash(const QOpenGLVersionProfile &v, size_t seed = 0)
{ {
return qHash(static_cast<int>(v.profile() * 1000) return qHash(static_cast<int>(v.profile() * 1000)
+ v.version().first * 100 + v.version().second * 10, seed); + v.version().first * 100 + v.version().second * 10, seed);

View File

@ -136,7 +136,7 @@ enum class Tag : quint32 {
aabg = IccTag('a', 'a', 'b', 'g'), aabg = IccTag('a', 'a', 'b', 'g'),
}; };
inline uint qHash(const Tag &key, uint seed = 0) inline size_t qHash(const Tag &key, size_t seed = 0)
{ {
return qHash(quint32(key), seed); return qHash(quint32(key), seed);
} }

View File

@ -156,7 +156,7 @@ protected:
int m_currentRowHeight; // Height of last row int m_currentRowHeight; // Height of last row
}; };
inline uint qHash(const QTextureGlyphCache::GlyphAndSubPixelPosition &g) inline size_t qHash(const QTextureGlyphCache::GlyphAndSubPixelPosition &g)
{ {
return (g.glyph << 8) | (g.subPixelPosition * 10).round().toInt(); return (g.glyph << 8) | (g.subPixelPosition * 10).round().toInt();
} }

View File

@ -783,7 +783,7 @@ bool QTransform::operator==(const QTransform &o) const
Returns the hash value for \a key, using Returns the hash value for \a key, using
\a seed to seed the calculation. \a seed to seed the calculation.
*/ */
uint qHash(const QTransform &key, uint seed) noexcept size_t qHash(const QTransform &key, size_t seed) noexcept
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;
seed = hash(seed, key.m11()); seed = hash(seed, key.m11());

View File

@ -206,7 +206,7 @@ private:
}; };
Q_DECLARE_TYPEINFO(QTransform, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QTransform, Q_MOVABLE_TYPE);
Q_GUI_EXPORT Q_DECL_CONST_FUNCTION uint qHash(const QTransform &key, uint seed = 0) noexcept; Q_GUI_EXPORT Q_DECL_CONST_FUNCTION size_t qHash(const QTransform &key, size_t seed = 0) noexcept;
/******* inlines *****/ /******* inlines *****/
inline QTransform::TransformationType QTransform::inline_type() const inline QTransform::TransformationType QTransform::inline_type() const

View File

@ -711,7 +711,7 @@ bool operator!=(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClear
\relates QRhiDepthStencilClearValue \relates QRhiDepthStencilClearValue
*/ */
uint qHash(const QRhiDepthStencilClearValue &v, uint seed) Q_DECL_NOTHROW size_t qHash(const QRhiDepthStencilClearValue &v, size_t seed) Q_DECL_NOTHROW
{ {
return seed * (uint(qFloor(qreal(v.depthClearValue()) * 100)) + v.stencilClearValue()); return seed * (uint(qFloor(qreal(v.depthClearValue()) * 100)) + v.stencilClearValue());
} }
@ -807,7 +807,7 @@ bool operator!=(const QRhiViewport &a, const QRhiViewport &b) Q_DECL_NOTHROW
\relates QRhiViewport \relates QRhiViewport
*/ */
uint qHash(const QRhiViewport &v, uint seed) Q_DECL_NOTHROW size_t qHash(const QRhiViewport &v, size_t seed) Q_DECL_NOTHROW
{ {
const std::array<float, 4> r = v.viewport(); const std::array<float, 4> r = v.viewport();
return seed + uint(r[0]) + uint(r[1]) + uint(r[2]) + uint(r[3]) return seed + uint(r[0]) + uint(r[1]) + uint(r[2]) + uint(r[3])
@ -898,7 +898,7 @@ bool operator!=(const QRhiScissor &a, const QRhiScissor &b) Q_DECL_NOTHROW
\relates QRhiScissor \relates QRhiScissor
*/ */
uint qHash(const QRhiScissor &v, uint seed) Q_DECL_NOTHROW size_t qHash(const QRhiScissor &v, size_t seed) Q_DECL_NOTHROW
{ {
const std::array<int, 4> r = v.scissor(); const std::array<int, 4> r = v.scissor();
return seed + uint(r[0]) + uint(r[1]) + uint(r[2]) + uint(r[3]); return seed + uint(r[0]) + uint(r[1]) + uint(r[2]) + uint(r[3]);
@ -1032,7 +1032,7 @@ bool operator!=(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b
\relates QRhiVertexInputBinding \relates QRhiVertexInputBinding
*/ */
uint qHash(const QRhiVertexInputBinding &v, uint seed) Q_DECL_NOTHROW size_t qHash(const QRhiVertexInputBinding &v, size_t seed) Q_DECL_NOTHROW
{ {
return seed + v.stride() + v.classification(); return seed + v.stride() + v.classification();
} }
@ -1185,7 +1185,7 @@ bool operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribut
\relates QRhiVertexInputAttribute \relates QRhiVertexInputAttribute
*/ */
uint qHash(const QRhiVertexInputAttribute &v, uint seed) Q_DECL_NOTHROW size_t qHash(const QRhiVertexInputAttribute &v, size_t seed) Q_DECL_NOTHROW
{ {
return seed + uint(v.binding()) + uint(v.location()) + uint(v.format()) + v.offset(); return seed + uint(v.binding()) + uint(v.location()) + uint(v.format()) + v.offset();
} }
@ -1246,7 +1246,7 @@ bool operator!=(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b)
\relates QRhiVertexInputLayout \relates QRhiVertexInputLayout
*/ */
uint qHash(const QRhiVertexInputLayout &v, uint seed) Q_DECL_NOTHROW size_t qHash(const QRhiVertexInputLayout &v, size_t seed) Q_DECL_NOTHROW
{ {
return qHash(v.m_bindings, seed) + qHash(v.m_attributes, seed); return qHash(v.m_bindings, seed) + qHash(v.m_attributes, seed);
} }
@ -1336,7 +1336,7 @@ bool operator!=(const QRhiShaderStage &a, const QRhiShaderStage &b) Q_DECL_NOTHR
\relates QRhiShaderStage \relates QRhiShaderStage
*/ */
uint qHash(const QRhiShaderStage &v, uint seed) Q_DECL_NOTHROW size_t qHash(const QRhiShaderStage &v, size_t seed) Q_DECL_NOTHROW
{ {
return v.type() + qHash(v.shader(), seed) + v.shaderVariant(); return v.type() + qHash(v.shader(), seed) + v.shaderVariant();
} }
@ -3182,7 +3182,7 @@ bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBind
\relates QRhiShaderResourceBinding \relates QRhiShaderResourceBinding
*/ */
uint qHash(const QRhiShaderResourceBinding &b, uint seed) Q_DECL_NOTHROW size_t qHash(const QRhiShaderResourceBinding &b, size_t seed) Q_DECL_NOTHROW
{ {
const QRhiShaderResourceBinding::Data *d = b.data(); const QRhiShaderResourceBinding::Data *d = b.data();
return seed + uint(d->binding) + 10 * uint(d->stage) + 100 * uint(d->type) return seed + uint(d->binding) + 10 * uint(d->stage) + 100 * uint(d->type)

View File

@ -94,7 +94,7 @@ Q_DECLARE_TYPEINFO(QRhiDepthStencilClearValue, Q_MOVABLE_TYPE);
Q_GUI_EXPORT bool operator==(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator==(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT bool operator!=(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator!=(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT uint qHash(const QRhiDepthStencilClearValue &v, uint seed = 0) Q_DECL_NOTHROW; Q_GUI_EXPORT size_t qHash(const QRhiDepthStencilClearValue &v, size_t seed = 0) Q_DECL_NOTHROW;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiDepthStencilClearValue &); Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiDepthStencilClearValue &);
#endif #endif
@ -126,7 +126,7 @@ Q_DECLARE_TYPEINFO(QRhiViewport, Q_MOVABLE_TYPE);
Q_GUI_EXPORT bool operator==(const QRhiViewport &a, const QRhiViewport &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator==(const QRhiViewport &a, const QRhiViewport &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT bool operator!=(const QRhiViewport &a, const QRhiViewport &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator!=(const QRhiViewport &a, const QRhiViewport &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT uint qHash(const QRhiViewport &v, uint seed = 0) Q_DECL_NOTHROW; Q_GUI_EXPORT size_t qHash(const QRhiViewport &v, size_t seed = 0) Q_DECL_NOTHROW;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiViewport &); Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiViewport &);
#endif #endif
@ -150,7 +150,7 @@ Q_DECLARE_TYPEINFO(QRhiScissor, Q_MOVABLE_TYPE);
Q_GUI_EXPORT bool operator==(const QRhiScissor &a, const QRhiScissor &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator==(const QRhiScissor &a, const QRhiScissor &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT bool operator!=(const QRhiScissor &a, const QRhiScissor &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator!=(const QRhiScissor &a, const QRhiScissor &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT uint qHash(const QRhiScissor &v, uint seed = 0) Q_DECL_NOTHROW; Q_GUI_EXPORT size_t qHash(const QRhiScissor &v, size_t seed = 0) Q_DECL_NOTHROW;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiScissor &); Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiScissor &);
#endif #endif
@ -185,7 +185,7 @@ Q_DECLARE_TYPEINFO(QRhiVertexInputBinding, Q_MOVABLE_TYPE);
Q_GUI_EXPORT bool operator==(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator==(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT bool operator!=(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator!=(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT uint qHash(const QRhiVertexInputBinding &v, uint seed = 0) Q_DECL_NOTHROW; Q_GUI_EXPORT size_t qHash(const QRhiVertexInputBinding &v, size_t seed = 0) Q_DECL_NOTHROW;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputBinding &); Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputBinding &);
#endif #endif
@ -229,7 +229,7 @@ Q_DECLARE_TYPEINFO(QRhiVertexInputAttribute, Q_MOVABLE_TYPE);
Q_GUI_EXPORT bool operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT bool operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT uint qHash(const QRhiVertexInputAttribute &v, uint seed = 0) Q_DECL_NOTHROW; Q_GUI_EXPORT size_t qHash(const QRhiVertexInputAttribute &v, size_t seed = 0) Q_DECL_NOTHROW;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputAttribute &); Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputAttribute &);
#endif #endif
@ -265,7 +265,7 @@ private:
QVarLengthArray<QRhiVertexInputAttribute, 8> m_attributes; QVarLengthArray<QRhiVertexInputAttribute, 8> m_attributes;
friend Q_GUI_EXPORT bool operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) Q_DECL_NOTHROW; friend Q_GUI_EXPORT bool operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) Q_DECL_NOTHROW;
friend Q_GUI_EXPORT uint qHash(const QRhiVertexInputLayout &v, uint seed) Q_DECL_NOTHROW; friend Q_GUI_EXPORT size_t qHash(const QRhiVertexInputLayout &v, size_t seed) Q_DECL_NOTHROW;
friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputLayout &); friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputLayout &);
}; };
@ -273,7 +273,7 @@ Q_DECLARE_TYPEINFO(QRhiVertexInputLayout, Q_MOVABLE_TYPE);
Q_GUI_EXPORT bool operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT bool operator!=(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator!=(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT uint qHash(const QRhiVertexInputLayout &v, uint seed = 0) Q_DECL_NOTHROW; Q_GUI_EXPORT size_t qHash(const QRhiVertexInputLayout &v, size_t seed = 0) Q_DECL_NOTHROW;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputLayout &); Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputLayout &);
#endif #endif
@ -310,7 +310,7 @@ Q_DECLARE_TYPEINFO(QRhiShaderStage, Q_MOVABLE_TYPE);
Q_GUI_EXPORT bool operator==(const QRhiShaderStage &a, const QRhiShaderStage &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator==(const QRhiShaderStage &a, const QRhiShaderStage &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT bool operator!=(const QRhiShaderStage &a, const QRhiShaderStage &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator!=(const QRhiShaderStage &a, const QRhiShaderStage &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT uint qHash(const QRhiShaderStage &s, uint seed = 0) Q_DECL_NOTHROW; Q_GUI_EXPORT size_t qHash(const QRhiShaderStage &s, size_t seed = 0) Q_DECL_NOTHROW;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderStage &); Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderStage &);
#endif #endif
@ -411,7 +411,7 @@ Q_DECLARE_TYPEINFO(QRhiShaderResourceBinding, Q_MOVABLE_TYPE);
Q_GUI_EXPORT bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) Q_DECL_NOTHROW;
Q_GUI_EXPORT uint qHash(const QRhiShaderResourceBinding &b, uint seed = 0) Q_DECL_NOTHROW; Q_GUI_EXPORT size_t qHash(const QRhiShaderResourceBinding &b, size_t seed = 0) Q_DECL_NOTHROW;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderResourceBinding &); Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderResourceBinding &);
#endif #endif

View File

@ -543,7 +543,7 @@ bool operator==(const QShader &lhs, const QShader &rhs) Q_DECL_NOTHROW
\relates QShader \relates QShader
*/ */
uint qHash(const QShader &s, uint seed) Q_DECL_NOTHROW size_t qHash(const QShader &s, size_t seed) Q_DECL_NOTHROW
{ {
uint h = s.stage(); uint h = s.stage();
for (auto it = s.d->shaders.constBegin(), itEnd = s.d->shaders.constEnd(); it != itEnd; ++it) for (auto it = s.d->shaders.constBegin(), itEnd = s.d->shaders.constEnd(); it != itEnd; ++it)
@ -596,7 +596,7 @@ bool operator==(const QShaderKey &lhs, const QShaderKey &rhs) Q_DECL_NOTHROW
\relates QShaderKey \relates QShaderKey
*/ */
uint qHash(const QShaderKey &k, uint seed) Q_DECL_NOTHROW size_t qHash(const QShaderKey &k, size_t seed) Q_DECL_NOTHROW
{ {
return seed + 10 * k.source() + k.sourceVersion().version() + k.sourceVersion().flags() + k.sourceVariant(); return seed + 10 * k.source() + k.sourceVersion().version() + k.sourceVersion().flags() + k.sourceVariant();
} }

View File

@ -158,7 +158,7 @@ private:
QShaderPrivate *d; QShaderPrivate *d;
friend struct QShaderPrivate; friend struct QShaderPrivate;
friend Q_GUI_EXPORT bool operator==(const QShader &, const QShader &) Q_DECL_NOTHROW; friend Q_GUI_EXPORT bool operator==(const QShader &, const QShader &) Q_DECL_NOTHROW;
friend Q_GUI_EXPORT uint qHash(const QShader &, uint) Q_DECL_NOTHROW; friend Q_GUI_EXPORT size_t qHash(const QShader &, size_t) Q_DECL_NOTHROW;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QShader &); friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QShader &);
#endif #endif
@ -190,7 +190,7 @@ private:
Q_DECLARE_TYPEINFO(QShaderKey, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QShaderKey, Q_MOVABLE_TYPE);
Q_GUI_EXPORT bool operator==(const QShader &lhs, const QShader &rhs) Q_DECL_NOTHROW; Q_GUI_EXPORT bool operator==(const QShader &lhs, const QShader &rhs) Q_DECL_NOTHROW;
Q_GUI_EXPORT uint qHash(const QShader &s, uint seed = 0) Q_DECL_NOTHROW; Q_GUI_EXPORT size_t qHash(const QShader &s, size_t seed = 0) Q_DECL_NOTHROW;
inline bool operator!=(const QShader &lhs, const QShader &rhs) Q_DECL_NOTHROW inline bool operator!=(const QShader &lhs, const QShader &rhs) Q_DECL_NOTHROW
{ {
@ -216,7 +216,7 @@ inline bool operator!=(const QShaderCode &lhs, const QShaderCode &rhs) Q_DECL_NO
return !(lhs == rhs); return !(lhs == rhs);
} }
Q_GUI_EXPORT uint qHash(const QShaderKey &k, uint seed = 0) Q_DECL_NOTHROW; Q_GUI_EXPORT size_t qHash(const QShaderKey &k, size_t seed = 0) Q_DECL_NOTHROW;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QShader &); Q_GUI_EXPORT QDebug operator<<(QDebug, const QShader &);

View File

@ -2086,7 +2086,7 @@ QString QFont::toString() const
\relates QFont \relates QFont
\since 5.3 \since 5.3
*/ */
uint qHash(const QFont &font, uint seed) noexcept size_t qHash(const QFont &font, size_t seed) noexcept
{ {
return qHash(QFontPrivate::get(font)->request, seed); return qHash(QFontPrivate::get(font)->request, seed);
} }

View File

@ -347,7 +347,7 @@ private:
Q_DECLARE_SHARED(QFont) Q_DECLARE_SHARED(QFont)
Q_GUI_EXPORT uint qHash(const QFont &font, uint seed = 0) noexcept; Q_GUI_EXPORT size_t qHash(const QFont &font, size_t seed = 0) noexcept;
inline bool QFont::bold() const inline bool QFont::bold() const
{ return weight() > Medium; } { return weight() > Medium; }

View File

@ -136,7 +136,7 @@ struct QFontDef
} }
}; };
inline uint qHash(const QFontDef &fd, uint seed = 0) noexcept inline size_t qHash(const QFontDef &fd, size_t seed = 0) noexcept
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;
seed = hash(seed, qRound64(fd.pixelSize*10000)); // use only 4 fractional digits seed = hash(seed, qRound64(fd.pixelSize*10000)); // use only 4 fractional digits

View File

@ -399,7 +399,7 @@ inline bool operator ==(const QFontEngine::FaceId &f1, const QFontEngine::FaceId
return f1.index == f2.index && f1.encoding == f2.encoding && f1.filename == f2.filename && f1.uuid == f2.uuid; return f1.index == f2.index && f1.encoding == f2.encoding && f1.filename == f2.filename && f1.uuid == f2.uuid;
} }
inline uint qHash(const QFontEngine::FaceId &f, uint seed = 0) inline size_t qHash(const QFontEngine::FaceId &f, size_t seed = 0)
noexcept(noexcept(qHash(f.filename))) noexcept(noexcept(qHash(f.filename)))
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;

View File

@ -323,7 +323,7 @@ bool QRawFont::operator==(const QRawFont &other) const
\relates QRawFont \relates QRawFont
\since 5.8 \since 5.8
*/ */
uint qHash(const QRawFont &font, uint seed) noexcept size_t qHash(const QRawFont &font, size_t seed) noexcept
{ {
return qHash(QRawFontPrivate::get(font)->fontEngine, seed); return qHash(QRawFontPrivate::get(font)->fontEngine, seed);
} }

View File

@ -156,7 +156,7 @@ Q_DECLARE_SHARED(QRawFont)
Q_DECLARE_OPERATORS_FOR_FLAGS(QRawFont::LayoutFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(QRawFont::LayoutFlags)
Q_GUI_EXPORT uint qHash(const QRawFont &font, uint seed = 0) noexcept; Q_GUI_EXPORT size_t qHash(const QRawFont &font, size_t seed = 0) noexcept;
inline QVector<QPointF> QRawFont::advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes, QRawFont::LayoutFlags layoutFlags) const inline QVector<QPointF> QRawFont::advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes, QRawFont::LayoutFlags layoutFlags) const
{ {

View File

@ -358,7 +358,7 @@ QVulkanInstance::~QVulkanInstance()
*/ */
/*! /*!
\fn uint qHash(const QVulkanLayer &key, uint seed) \fn size_t qHash(const QVulkanLayer &key, size_t seed)
\since 5.10 \since 5.10
\relates QVulkanLayer \relates QVulkanLayer
@ -401,7 +401,7 @@ QVulkanInstance::~QVulkanInstance()
*/ */
/*! /*!
\fn uint qHash(const QVulkanExtension &key, uint seed) \fn size_t qHash(const QVulkanExtension &key, size_t seed)
\since 5.10 \since 5.10
\relates QVulkanExtension \relates QVulkanExtension

View File

@ -91,7 +91,7 @@ inline bool operator==(const QVulkanLayer &lhs, const QVulkanLayer &rhs) noexcep
inline bool operator!=(const QVulkanLayer &lhs, const QVulkanLayer &rhs) noexcept inline bool operator!=(const QVulkanLayer &lhs, const QVulkanLayer &rhs) noexcept
{ return !(lhs == rhs); } { return !(lhs == rhs); }
inline uint qHash(const QVulkanLayer &key, uint seed = 0) noexcept inline size_t qHash(const QVulkanLayer &key, size_t seed = 0) noexcept
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;
seed = hash(seed, key.name); seed = hash(seed, key.name);
@ -114,7 +114,7 @@ inline bool operator==(const QVulkanExtension &lhs, const QVulkanExtension &rhs)
inline bool operator!=(const QVulkanExtension &lhs, const QVulkanExtension &rhs) noexcept inline bool operator!=(const QVulkanExtension &lhs, const QVulkanExtension &rhs) noexcept
{ return !(lhs == rhs); } { return !(lhs == rhs); }
inline uint qHash(const QVulkanExtension &key, uint seed = 0) noexcept inline size_t qHash(const QVulkanExtension &key, size_t seed = 0) noexcept
{ {
QtPrivate::QHashCombine hash; QtPrivate::QHashCombine hash;
seed = hash(seed, key.name); seed = hash(seed, key.name);

View File

@ -1333,7 +1333,7 @@ QDebug operator<<(QDebug d, const QHostAddress &address)
\relates QHostAddress \relates QHostAddress
Returns a hash of the host address \a key, using \a seed to seed the calculation. Returns a hash of the host address \a key, using \a seed to seed the calculation.
*/ */
uint qHash(const QHostAddress &key, uint seed) noexcept size_t qHash(const QHostAddress &key, size_t seed) noexcept
{ {
return qHashBits(key.d->a6.c, 16, seed); return qHashBits(key.d->a6.c, 16, seed);
} }

View File

@ -66,7 +66,7 @@ typedef QIPv6Address Q_IPV6ADDR;
class QHostAddress; class QHostAddress;
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed = 0) noexcept; Q_NETWORK_EXPORT size_t qHash(const QHostAddress &key, size_t seed = 0) noexcept;
class Q_NETWORK_EXPORT QHostAddress class Q_NETWORK_EXPORT QHostAddress
{ {
@ -154,7 +154,7 @@ public:
static QPair<QHostAddress, int> parseSubnet(const QString &subnet); static QPair<QHostAddress, int> parseSubnet(const QString &subnet);
friend Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed) noexcept; friend Q_NETWORK_EXPORT size_t qHash(const QHostAddress &key, size_t seed) noexcept;
protected: protected:
friend class QHostAddressPrivate; friend class QHostAddressPrivate;
QExplicitlySharedDataPointer<QHostAddressPrivate> d; QExplicitlySharedDataPointer<QHostAddressPrivate> d;

View File

@ -232,20 +232,20 @@ Q_NETWORK_EXPORT bool operator==(const QOcspResponse &lhs, const QOcspResponse &
*/ */
/*! /*!
\fn uint qHash(const QOcspResponse &response, uint seed) \fn size_t qHash(const QOcspResponse &response, size_t seed)
Returns the hash value for the \a response, using \a seed to seed the calculation. Returns the hash value for the \a response, using \a seed to seed the calculation.
\since 5.13 \since 5.13
\relates QHash \relates QHash
*/ */
uint qHash(const QOcspResponse &response, uint seed) noexcept size_t qHash(const QOcspResponse &response, size_t seed) noexcept
{ {
const QOcspResponsePrivate *d = response.d.data(); const QOcspResponsePrivate *d = response.d.data();
Q_ASSERT(d); Q_ASSERT(d);
QtPrivate::QHashCombine hasher; QtPrivate::QHashCombine hasher;
uint hash = hasher(seed, int(d->certificateStatus)); size_t hash = hasher(seed, int(d->certificateStatus));
hash = hasher(hash, int(d->revocationReason)); hash = hasher(hash, int(d->revocationReason));
if (!d->signerCert.isNull()) if (!d->signerCert.isNull())
hash = hasher(hash, d->signerCert); hash = hasher(hash, d->signerCert);

View File

@ -73,7 +73,7 @@ enum class QOcspRevocationReason
}; };
class QOcspResponse; class QOcspResponse;
Q_NETWORK_EXPORT uint qHash(const QOcspResponse &response, uint seed = 0) noexcept; Q_NETWORK_EXPORT size_t qHash(const QOcspResponse &response, size_t seed = 0) noexcept;
class QOcspResponsePrivate; class QOcspResponsePrivate;
class Q_NETWORK_EXPORT QOcspResponse class Q_NETWORK_EXPORT QOcspResponse
@ -100,7 +100,7 @@ private:
friend class QSslSocketBackendPrivate; friend class QSslSocketBackendPrivate;
friend Q_NETWORK_EXPORT bool operator==(const QOcspResponse &lhs, const QOcspResponse &rhs); friend Q_NETWORK_EXPORT bool operator==(const QOcspResponse &lhs, const QOcspResponse &rhs);
friend Q_NETWORK_EXPORT uint qHash(const QOcspResponse &response, uint seed) noexcept; friend Q_NETWORK_EXPORT size_t qHash(const QOcspResponse &response, size_t seed) noexcept;
QSharedDataPointer<QOcspResponsePrivate> d; QSharedDataPointer<QOcspResponsePrivate> d;
}; };

View File

@ -761,7 +761,7 @@ QString QSslCertificate::subjectDisplayName() const
} }
/*! /*!
\fn uint qHash(const QSslCertificate &key, uint seed) \fn size_t qHash(const QSslCertificate &key, size_t seed)
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
\since 5.4 \since 5.4

View File

@ -65,7 +65,7 @@ class QStringList;
class QSslCertificate; class QSslCertificate;
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
Q_NETWORK_EXPORT uint qHash(const QSslCertificate &key, uint seed = 0) noexcept; Q_NETWORK_EXPORT size_t qHash(const QSslCertificate &key, size_t seed = 0) noexcept;
class QSslCertificatePrivate; class QSslCertificatePrivate;
class Q_NETWORK_EXPORT QSslCertificate class Q_NETWORK_EXPORT QSslCertificate
@ -170,7 +170,7 @@ private:
friend class QSslCertificatePrivate; friend class QSslCertificatePrivate;
friend class QSslSocketBackendPrivate; friend class QSslSocketBackendPrivate;
friend Q_NETWORK_EXPORT uint qHash(const QSslCertificate &key, uint seed) noexcept; friend Q_NETWORK_EXPORT size_t qHash(const QSslCertificate &key, size_t seed) noexcept;
}; };
Q_DECLARE_SHARED(QSslCertificate) Q_DECLARE_SHARED(QSslCertificate)

View File

@ -72,7 +72,7 @@ bool QSslCertificate::operator==(const QSslCertificate &other) const
return false; return false;
} }
uint qHash(const QSslCertificate &key, uint seed) noexcept size_t qHash(const QSslCertificate &key, size_t seed) noexcept
{ {
if (X509 * const x509 = key.d->x509) { if (X509 * const x509 = key.d->x509) {
const EVP_MD *sha1 = q_EVP_sha1(); const EVP_MD *sha1 = q_EVP_sha1();

View File

@ -64,7 +64,7 @@ bool QSslCertificate::operator==(const QSslCertificate &other) const
return d->derData == other.d->derData; return d->derData == other.d->derData;
} }
uint qHash(const QSslCertificate &key, uint seed) noexcept size_t qHash(const QSslCertificate &key, size_t seed) noexcept
{ {
// DER is the native encoding here, so toDer() is just "return d->derData": // DER is the native encoding here, so toDer() is just "return d->derData":
return qHash(key.toDer(), seed); return qHash(key.toDer(), seed);

View File

@ -316,7 +316,7 @@ QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparam)
Returns an hash value for \a dhparam, using \a seed to seed Returns an hash value for \a dhparam, using \a seed to seed
the calculation. the calculation.
*/ */
uint qHash(const QSslDiffieHellmanParameters &dhparam, uint seed) noexcept size_t qHash(const QSslDiffieHellmanParameters &dhparam, size_t seed) noexcept
{ {
return qHash(dhparam.d->derData, seed); return qHash(dhparam.d->derData, seed);
} }

View File

@ -56,7 +56,7 @@ class QSslDiffieHellmanParametersPrivate;
class QSslDiffieHellmanParameters; class QSslDiffieHellmanParameters;
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
Q_NETWORK_EXPORT uint qHash(const QSslDiffieHellmanParameters &dhparam, uint seed = 0) noexcept; Q_NETWORK_EXPORT size_t qHash(const QSslDiffieHellmanParameters &dhparam, size_t seed = 0) noexcept;
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
class QDebug; class QDebug;
@ -106,7 +106,7 @@ private:
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
friend Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparam); friend Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparam);
#endif #endif
friend Q_NETWORK_EXPORT uint qHash(const QSslDiffieHellmanParameters &dhparam, uint seed) noexcept; friend Q_NETWORK_EXPORT size_t qHash(const QSslDiffieHellmanParameters &dhparam, size_t seed) noexcept;
}; };
Q_DECLARE_SHARED(QSslDiffieHellmanParameters) Q_DECLARE_SHARED(QSslDiffieHellmanParameters)

View File

@ -156,7 +156,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn uint qHash(QSslEllipticCurve curve, uint seed) \fn size_t qHash(QSslEllipticCurve curve, size_t seed)
\since 5.5 \since 5.5
\relates QHash \relates QHash

View File

@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
class QSslEllipticCurve; class QSslEllipticCurve;
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
Q_DECL_CONSTEXPR uint qHash(QSslEllipticCurve curve, uint seed = 0) noexcept; Q_DECL_CONSTEXPR size_t qHash(QSslEllipticCurve curve, size_t seed = 0) noexcept;
class QSslEllipticCurve { class QSslEllipticCurve {
public: public:
@ -78,7 +78,7 @@ private:
int id; int id;
friend Q_DECL_CONSTEXPR bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept; friend Q_DECL_CONSTEXPR bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept;
friend Q_DECL_CONSTEXPR uint qHash(QSslEllipticCurve curve, uint seed) noexcept; friend Q_DECL_CONSTEXPR size_t qHash(QSslEllipticCurve curve, size_t seed) noexcept;
friend class QSslContext; friend class QSslContext;
friend class QSslSocketPrivate; friend class QSslSocketPrivate;
@ -87,7 +87,7 @@ private:
Q_DECLARE_TYPEINFO(QSslEllipticCurve, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(QSslEllipticCurve, Q_PRIMITIVE_TYPE);
Q_DECL_CONSTEXPR inline uint qHash(QSslEllipticCurve curve, uint seed) noexcept Q_DECL_CONSTEXPR inline size_t qHash(QSslEllipticCurve curve, size_t seed) noexcept
{ return qHash(curve.id, seed); } { return qHash(curve.id, seed); }
Q_DECL_CONSTEXPR inline bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept Q_DECL_CONSTEXPR inline bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept

Some files were not shown because too many files have changed in this diff Show More