QMap, QHash: make key_iterator satisfy the DefaultConstructible concept

Change-Id: Ifc3f481ddb902b26c217516412c93a4a39a32b1c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
bb10
Anton Kudryavtsev 2017-03-17 00:07:57 +03:00
parent c1a2f97a3b
commit 4a97e3b98a
4 changed files with 10 additions and 0 deletions

View File

@ -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(); }

View File

@ -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(); }

View File

@ -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()

View File

@ -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()