diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 97dda58748..bf5031523d 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -769,6 +769,34 @@ uint qt_hash(QStringView key, uint chained) noexcept Returns the hash value for the \a key, using \a seed to seed the calculation. */ +/*! \fn size_t qHash(char8_t key, size_t seed = 0) + \relates QHash + \since 6.0 + + Returns the hash value for the \a key, using \a seed to seed the calculation. +*/ + +/*! \fn size_t qHash(char16_t key, size_t seed = 0) + \relates QHash + \since 6.0 + + Returns the hash value for the \a key, using \a seed to seed the calculation. +*/ + +/*! \fn size_t qHash(char32_t key, size_t seed = 0) + \relates QHash + \since 6.0 + + Returns the hash value for the \a key, using \a seed to seed the calculation. +*/ + +/*! \fn size_t qHash(wchar_t key, size_t seed = 0) + \relates QHash + \since 6.0 + + Returns the hash value for the \a key, using \a seed to seed the calculation. +*/ + /*! \fn size_t qHash(float key, size_t seed) noexcept \relates QHash \since 5.3 @@ -870,6 +898,13 @@ size_t qHash(long double key, size_t seed) noexcept Returns the hash value for the \a key, using \a seed to seed the calculation. */ +/*! \fn template size_t qHash(std::nullptr_t key, size_t seed = 0) + \relates QHash + \since 6.0 + + Returns the hash value for the \a key, using \a seed to seed the calculation. +*/ + /*! \class QHash \inmodule QtCore diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h index e52688b88d..aaa7758758 100644 --- a/src/corelib/tools/qhashfunctions.h +++ b/src/corelib/tools/qhashfunctions.h @@ -95,6 +95,7 @@ Q_DECL_CONST_FUNCTION constexpr size_t hash(size_t key, size_t seed) noexcept Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHashBits(const void *p, size_t size, size_t seed = 0) noexcept; +// C++ builtin types 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); } Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(uchar key, size_t seed = 0) noexcept @@ -132,6 +133,26 @@ Q_CORE_EXPORT Q_DECL_CONST_FUNCTION size_t qHash(double key, size_t seed = 0) no #if !defined(Q_OS_DARWIN) || defined(Q_CLANG_QDOC) Q_CORE_EXPORT Q_DECL_CONST_FUNCTION size_t qHash(long double key, size_t seed = 0) noexcept; #endif +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(wchar_t key, size_t seed = 0) noexcept +{ return QHashPrivate::hash(size_t(key), seed); } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(char16_t key, size_t seed = 0) noexcept +{ return QHashPrivate::hash(size_t(key), seed); } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(char32_t key, size_t seed = 0) noexcept +{ return QHashPrivate::hash(size_t(key), seed); } +#ifdef __cpp_char8_t +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline size_t qHash(char8_t key, size_t seed = 0) noexcept +{ return QHashPrivate::hash(size_t(key), seed); } +#endif +template inline size_t qHash(const T *key, size_t seed = 0) noexcept +{ + return qHash(reinterpret_cast(key), seed); +} +Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(std::nullptr_t, size_t seed = 0) noexcept +{ + return seed; +} + +// (some) Qt types 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 size_t qHash(const QByteArray &key, size_t seed = 0) noexcept; #if QT_STRINGVIEW_LEVEL < 2 @@ -143,15 +164,6 @@ Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QBitArray &key, size_t see 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_DECL_CONST_FUNCTION constexpr inline size_t qHash(std::nullptr_t, size_t seed = 0) noexcept -{ - return seed; -} - -template inline size_t qHash(const T *key, size_t seed = 0) noexcept -{ - return qHash(reinterpret_cast(key), seed); -} template inline size_t qHash(const T &t, size_t seed) noexcept(noexcept(qHash(t))) { return qHash(t) ^ seed; }