\relates QHash
\since 5.0
*/
-uint qHash(const QUrl &url, uint seed)
+uint qHash(const QUrl &url, uint seed) Q_DECL_NOTHROW
{
if (!url.d)
return qHash(-1, seed); // the hash of an unset port (-1)
static QByteArray toAce(const QString &);
static QStringList idnWhitelist();
static void setIdnWhitelist(const QStringList &);
- friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed = 0);
+ friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed = 0) Q_DECL_NOTHROW;
private:
QUrlPrivate *d;
\relates QUuid
Returns a hash of the UUID \a uuid, using \a seed to seed the calculation.
*/
-uint qHash(const QUuid &uuid, uint seed)
+uint qHash(const QUuid &uuid, uint seed) Q_DECL_NOTHROW
{
return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16)
^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3])
Q_CORE_EXPORT QDebug operator<<(QDebug, const QUuid &);
#endif
-Q_CORE_EXPORT uint qHash(const QUuid &uuid, uint seed = 0);
+Q_CORE_EXPORT uint qHash(const QUuid &uuid, uint seed = 0) Q_DECL_NOTHROW;
QT_END_NAMESPACE
{
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QBitArray &);
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QBitArray &);
- friend Q_CORE_EXPORT uint qHash(const QBitArray &key, uint seed);
+ friend Q_CORE_EXPORT uint qHash(const QBitArray &key, uint seed) Q_DECL_NOTHROW;
QByteArray d;
public:
Returns the hash value for the \a key, using \a seed to seed the calculation.
*/
-uint qHash(const QDate &key, uint seed)
+uint qHash(const QDate &key, uint seed) Q_DECL_NOTHROW
{
return qHash(key.toJulianDay(), seed);
}
Returns the hash value for the \a key, using \a seed to seed the calculation.
*/
-uint qHash(const QTime &key, uint seed)
+uint qHash(const QTime &key, uint seed) Q_DECL_NOTHROW
{
- return QTime(0, 0, 0, 0).msecsTo(key) ^ seed;
+ return qHash(QTime(0, 0, 0, 0).msecsTo(key), seed);
}
#ifndef QT_BOOTSTRAPPED
Q_CORE_EXPORT QDebug operator<<(QDebug, const QDateTime &);
#endif
+// QDateTime is not noexcept for now -- to be revised once
+// timezone and calendaring support is added
Q_CORE_EXPORT uint qHash(const QDateTime &key, uint seed = 0);
-Q_CORE_EXPORT uint qHash(const QDate &key, uint seed = 0);
-Q_CORE_EXPORT uint qHash(const QTime &key, uint seed = 0);
+Q_CORE_EXPORT uint qHash(const QDate &key, uint seed = 0) Q_DECL_NOTHROW;
+Q_CORE_EXPORT uint qHash(const QTime &key, uint seed = 0) Q_DECL_NOTHROW;
QT_END_NAMESPACE
(for instance, gcc 4.4 does that even at -O0).
*/
-static inline uint hash(const uchar *p, int len, uint seed)
+static inline uint hash(const uchar *p, int len, uint seed) Q_DECL_NOTHROW
{
uint h = seed;
return h;
}
-static inline uint hash(const QChar *p, int len, uint seed)
+static inline uint hash(const QChar *p, int len, uint seed) Q_DECL_NOTHROW
{
uint h = seed;
return h;
}
-uint qHash(const QByteArray &key, uint seed)
+uint qHash(const QByteArray &key, uint seed) Q_DECL_NOTHROW
{
return hash(reinterpret_cast<const uchar *>(key.constData()), key.size(), seed);
}
-uint qHash(const QString &key, uint seed)
+uint qHash(const QString &key, uint seed) Q_DECL_NOTHROW
{
return hash(key.unicode(), key.size(), seed);
}
-uint qHash(const QStringRef &key, uint seed)
+uint qHash(const QStringRef &key, uint seed) Q_DECL_NOTHROW
{
return hash(key.unicode(), key.size(), seed);
}
-uint qHash(const QBitArray &bitArray, uint seed)
+uint qHash(const QBitArray &bitArray, uint seed) Q_DECL_NOTHROW
{
int m = bitArray.d.size() - 1;
uint result = hash(reinterpret_cast<const uchar *>(bitArray.d.constData()), qMax(0, m), seed);
return result;
}
-uint qHash(QLatin1String key, uint seed)
+uint qHash(QLatin1String key, uint seed) Q_DECL_NOTHROW
{
return hash(reinterpret_cast<const uchar *>(key.data()), key.size(), seed);
}
This function must *never* change its results.
*/
-uint qt_hash(const QString &key)
+uint qt_hash(const QString &key) Q_DECL_NOTHROW
{
const QChar *p = key.unicode();
int n = key.size();
class QStringRef;
class QLatin1String;
-inline uint qHash(char key, uint seed = 0) { return uint(key) ^ seed; }
-inline uint qHash(uchar key, uint seed = 0) { return uint(key) ^ seed; }
-inline uint qHash(signed char key, uint seed = 0) { return uint(key) ^ seed; }
-inline uint qHash(ushort key, uint seed = 0) { return uint(key) ^ seed; }
-inline uint qHash(short key, uint seed = 0) { return uint(key) ^ seed; }
-inline uint qHash(uint key, uint seed = 0) { return key ^ seed; }
-inline uint qHash(int key, uint seed = 0) { return uint(key) ^ seed; }
-inline uint qHash(ulong key, uint seed = 0)
+inline uint qHash(char key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
+inline uint qHash(uchar key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
+inline uint qHash(signed char key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
+inline uint qHash(ushort key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
+inline uint qHash(short key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
+inline uint qHash(uint key, uint seed = 0) Q_DECL_NOTHROW { return key ^ seed; }
+inline uint qHash(int key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
+inline uint qHash(ulong key, uint seed = 0) Q_DECL_NOTHROW
{
if (sizeof(ulong) > sizeof(uint)) {
return uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U)) ^ seed;
return uint(key & (~0U)) ^ seed;
}
}
-inline uint qHash(long key, uint seed = 0) { return qHash(ulong(key), seed); }
-inline uint qHash(quint64 key, uint seed = 0)
+inline uint qHash(long key, uint seed = 0) Q_DECL_NOTHROW { return qHash(ulong(key), seed); }
+inline uint qHash(quint64 key, uint seed = 0) Q_DECL_NOTHROW
{
if (sizeof(quint64) > sizeof(uint)) {
return uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U)) ^ seed;
return uint(key & (~0U)) ^ seed;
}
}
-inline uint qHash(qint64 key, uint seed = 0) { return qHash(quint64(key), seed); }
-inline uint qHash(QChar key, uint seed = 0) { return qHash(key.unicode(), seed); }
-Q_CORE_EXPORT uint qHash(const QByteArray &key, uint seed = 0);
-Q_CORE_EXPORT uint qHash(const QString &key, uint seed = 0);
-Q_CORE_EXPORT uint qHash(const QStringRef &key, uint seed = 0);
-Q_CORE_EXPORT uint qHash(const QBitArray &key, uint seed = 0);
-Q_CORE_EXPORT uint qHash(QLatin1String key, uint seed = 0);
-Q_CORE_EXPORT uint qt_hash(const QString &key);
+inline uint qHash(qint64 key, uint seed = 0) Q_DECL_NOTHROW { return qHash(quint64(key), seed); }
+inline uint qHash(QChar key, uint seed = 0) Q_DECL_NOTHROW { return qHash(key.unicode(), seed); }
+Q_CORE_EXPORT uint qHash(const QByteArray &key, uint seed = 0) Q_DECL_NOTHROW;
+Q_CORE_EXPORT uint qHash(const QString &key, uint seed = 0) Q_DECL_NOTHROW;
+Q_CORE_EXPORT uint qHash(const QStringRef &key, uint seed = 0) Q_DECL_NOTHROW;
+Q_CORE_EXPORT uint qHash(const QBitArray &key, uint seed = 0) Q_DECL_NOTHROW;
+Q_CORE_EXPORT uint qHash(QLatin1String key, uint seed = 0) Q_DECL_NOTHROW;
+Q_CORE_EXPORT uint qt_hash(const QString &key) Q_DECL_NOTHROW;
#if defined(Q_CC_MSVC)
#pragma warning( push )
#pragma warning( disable : 4311 ) // disable pointer truncation warning
#endif
-template <class T> inline uint qHash(const T *key, uint seed = 0)
+template <class T> inline uint qHash(const T *key, uint seed = 0) Q_DECL_NOTHROW
{
return qHash(reinterpret_cast<quintptr>(key), seed);
}
#pragma warning( pop )
#endif
-template<typename T> inline uint qHash(const T &t, uint seed) { return (qHash(t) ^ seed); }
+template<typename T> inline uint qHash(const T &t, uint seed)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t)))
+{ return (qHash(t) ^ seed); }
template <typename T1, typename T2> inline uint qHash(const QPair<T1, T2> &key, uint seed = 0)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed)))
{
uint h1 = qHash(key.first, seed);
uint h2 = qHash(key.second, seed);
uint qHash(const QHostAddress &key, uint seed)
{
+ // both lines might throw
QT_ENSURE_PARSED(&key);
return qHash(QByteArray::fromRawData(reinterpret_cast<const char *>(key.d->a6.c), 16), seed);
}