summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlist.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-04-08 19:44:48 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-04-20 07:41:44 +0000
commit5fdc64f5666d094e34e1373e75ae6e50239d9622 (patch)
tree51a26d00d1d503d4cf8b453c4a4e05de5e0c2051 /src/corelib/tools/qlist.h
parent1b5f29e28a7022f6cde5232eaad2e8f73bc7ffcc (diff)
Add qHash(QList)
QLists can be compared for equality, so qHash should be overloaded, too. [ChangeLog][QtCore][QList] Added qHash(QList). Change-Id: I9ad91811f12479764cc17d87192539612ceb0b4c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools/qlist.h')
-rw-r--r--src/corelib/tools/qlist.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 34ebedce3b..85e4570f45 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -38,6 +38,7 @@
#include <QtCore/qiterator.h>
#include <QtCore/qrefcount.h>
#include <QtCore/qarraydata.h>
+#include <QtCore/qhashfunctions.h>
#include <iterator>
#include <list>
@@ -1022,6 +1023,13 @@ Q_DECLARE_SEQUENTIAL_ITERATOR(List)
Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(List)
template <typename T>
+uint qHash(const QList<T> &key, uint seed = 0)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))
+{
+ return qHashRange(key.cbegin(), key.cend(), seed);
+}
+
+template <typename T>
bool operator<(const QList<T> &lhs, const QList<T> &rhs)
Q_DECL_NOEXCEPT_EXPR(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(),
rhs.begin(), rhs.end())))