From 87155a8d651c94872207cf2a1b85a92d5c509073 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 8 Apr 2015 19:44:48 +0200 Subject: Add qHash(QRegExp) and qHash(QRegularExpression) QReg*Exp*s can be compared for equality, so qHash should be overloaded, too. There was a (poor) private implementation of qHash(QRegExpEngineKey) already, which has now been replaced with a better one (the old one didn't take into account all the fields that make up equality, producing unnecessary collisions). [ChangeLog][QtCore][QRegExp] Added qHash(QRegExp). [ChangeLog][QtCore][QRegularExpression] Added qHash(QRegularExpression). Change-Id: I1d22fbcc0508018a3f94b4c24571b13ba6e07df2 Reviewed-by: Giuseppe D'Angelo --- src/corelib/tools/qregularexpression.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/corelib/tools/qregularexpression.cpp') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 9950b90720..18dd2d12c2 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -38,6 +38,7 @@ #ifndef QT_NO_REGULAREXPRESSION #include +#include #include #include #include @@ -1837,6 +1838,21 @@ bool QRegularExpression::operator==(const QRegularExpression &re) const \sa operator==() */ +/*! + \since 5.6 + \relates QRegularExpression + + Returns the hash value for \a key, using + \a seed to seed the calculation. +*/ +uint qHash(const QRegularExpression &key, uint seed) Q_DECL_NOTHROW +{ + QtPrivate::QHashCombine hash; + seed = hash(seed, key.d->pattern); + seed = hash(seed, key.d->patternOptions); + return seed; +} + /*! Escapes all characters of \a str so that they no longer have any special meaning when used as a regular expression pattern string, and returns -- cgit v1.2.3