summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Kudryavtsev <antkudr@mail.ru>2017-03-17 00:07:57 +0300
committerAnton Kudryavtsev <antkudr@mail.ru>2017-03-20 04:36:42 +0000
commit4a97e3b98a40e6d35a4e63e171319ed02961a0cc (patch)
tree8fd836710ceec839bd9e273a6de86bc7fe34c04b
parentc1a2f97a3b3a8c058b1760b57e5c83bf7815b84a (diff)
QMap, QHash: make key_iterator satisfy the DefaultConstructible concept
Change-Id: Ifc3f481ddb902b26c217516412c93a4a39a32b1c Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
-rw-r--r--src/corelib/tools/qhash.h1
-rw-r--r--src/corelib/tools/qmap.h1
-rw-r--r--tests/auto/corelib/tools/qhash/tst_qhash.cpp4
-rw-r--r--tests/auto/corelib/tools/qmap/tst_qmap.cpp4
4 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 66b5e75a1a..c59f789cb2 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -432,6 +432,7 @@ public:
typedef const Key *pointer;
typedef const Key &reference;
+ key_iterator() = default;
explicit key_iterator(const_iterator o) : i(o) { }
const Key &operator*() const { return i.key(); }
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index e6da2820f8..3ee6ab8c58 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -531,6 +531,7 @@ public:
typedef const Key *pointer;
typedef const Key &reference;
+ key_iterator() = default;
explicit key_iterator(const_iterator o) : i(o) { }
const Key &operator*() const { return i.key(); }
diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
index 0b864e71d4..0c5f1a7afb 100644
--- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp
+++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
@@ -1053,6 +1053,10 @@ void tst_QHash::keyIterator()
QCOMPARE(*(--key_it), (--it).key());
QCOMPARE(std::count(hash.keyBegin(), hash.keyEnd(), 99), 1);
+
+ // DefaultConstructible test
+ typedef QHash<int, int>::key_iterator keyIterator;
+ Q_STATIC_ASSERT(std::is_default_constructible<keyIterator>::value);
}
void tst_QHash::rehash_isnt_quadratic()
diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
index 8aa7a3e518..f42ffc0471 100644
--- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp
+++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
@@ -857,6 +857,10 @@ void tst_QMap::keyIterator()
QCOMPARE(*(--key_it), (--it).key());
QCOMPARE(std::count(map.keyBegin(), map.keyEnd(), 99), 1);
+
+ // DefaultConstructible test
+ typedef QMap<int, int>::key_iterator keyIterator;
+ Q_STATIC_ASSERT(std::is_default_constructible<keyIterator>::value);
}
void tst_QMap::keys_values_uniqueKeys()