summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qset.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-08-14 11:22:23 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-01-18 19:36:06 +0100
commitb8e46fce5c70c399c615e1b846076f379db173c5 (patch)
treed91cca50e2039845328e25c2ddf8188ea122d0f7 /src/corelib/tools/qset.h
parent70e3935c38c077e35629a6651479a8a9f9e9f528 (diff)
Add qHash() overload for QSet
...using qHashRangeCommutative(). Also add a test. [ChangeLog][QtCore][QSet] Can now be used as the key in QSet, QHash. Change-Id: Ie7c81d257a3b324fc03d394fa7c9fcf0c6fb062a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qset.h')
-rw-r--r--src/corelib/tools/qset.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index 662afbf84a..baa412a550 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -237,6 +237,15 @@ private:
}
};
+template <typename T>
+uint qHash(const QSet<T> &key, uint seed = 0)
+Q_DECL_NOEXCEPT_EXPR(noexcept(qHashRangeCommutative(key.begin(), key.end(), seed)))
+{
+ return qHashRangeCommutative(key.begin(), key.end(), seed);
+}
+
+// inline function implementations
+
template <class T>
Q_INLINE_TEMPLATE void QSet<T>::reserve(int asize) { q_hash.reserve(asize); }