From 881746fd74d475265e442a1dc02b32ddb6c2d898 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 28 May 2010 14:41:27 +0200 Subject: QMultiMap/QMultiHash: must qualify identifier to find this declaration in dependent base class This is required as some compiler such as clang or rvct respect the standard more than gcc Reviewed-by: thiago Reviewed-by: hjk --- src/corelib/tools/qhash.h | 9 ++------- src/corelib/tools/qmap.h | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 05eae42..1d206ce 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -927,7 +927,7 @@ public: { return QHash::insertMulti(key, value); } inline QMultiHash &operator+=(const QMultiHash &other) - { unite(other); return *this; } + { this->unite(other); return *this; } inline QMultiHash operator+(const QMultiHash &other) const { QMultiHash result = *this; result += other; return result; } @@ -1002,12 +1002,7 @@ Q_INLINE_TEMPLATE int QMultiHash::remove(const Key &key, const T &value) typename QHash::iterator end(QHash::end()); while (i != end && i.key() == key) { if (i.value() == value) { -#if defined(Q_CC_RVCT) - // RVCT has problems with scoping, apparently. - i = QHash::erase(i); -#else - i = erase(i); -#endif + i = this->erase(i); ++n; } else { ++i; diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 4679812..75e73f2 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -953,7 +953,7 @@ public: { return QMap::insertMulti(key, value); } inline QMultiMap &operator+=(const QMultiMap &other) - { unite(other); return *this; } + { this->unite(other); return *this; } inline QMultiMap operator+(const QMultiMap &other) const { QMultiMap result = *this; result += other; return result; } @@ -1028,12 +1028,7 @@ Q_INLINE_TEMPLATE int QMultiMap::remove(const Key &key, const T &value) typename QMap::iterator end(QMap::end()); while (i != end && !qMapLessThanKey(key, i.key())) { if (i.value() == value) { -#if defined(Q_CC_RVCT) - // RVCT has problems with scoping, apparently. - i = QMap::erase(i); -#else - i = erase(i); -#endif + i = this->erase(i); ++n; } else { ++i; -- cgit v0.12 From 9228b527f2fa95aad7f34cbc44905fb8b371bbf7 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 28 May 2010 15:43:28 +0200 Subject: test QMultiMap::operator+= and QMultiHash::operator+= --- tests/auto/qhash/tst_qhash.cpp | 20 ++++++++++++++++++++ tests/auto/qmap/tst_qmap.cpp | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/tests/auto/qhash/tst_qhash.cpp b/tests/auto/qhash/tst_qhash.cpp index 59576d9..3a7b54a 100644 --- a/tests/auto/qhash/tst_qhash.cpp +++ b/tests/auto/qhash/tst_qhash.cpp @@ -1154,6 +1154,26 @@ void tst_QHash::qmultihash_specific() QVERIFY(i.key() == 9); QVERIFY(i.value() == 98); } + + { + QMultiHash map1; + map1.insert(42, 1); + map1.insert(10, 2); + map1.insert(48, 3); + QMultiHash map2; + map2.insert(8, 4); + map2.insert(42, 5); + map2.insert(95, 12); + + map1+=map2; + map2.insert(42, 1); + map2.insert(10, 2); + map2.insert(48, 3); + QCOMPARE(map1.count(), map2.count()); + QVERIFY(map1.remove(42,5)); + QVERIFY(map2.remove(42,5)); + QVERIFY(map1 == map2); + } } template diff --git a/tests/auto/qmap/tst_qmap.cpp b/tests/auto/qmap/tst_qmap.cpp index d3ed76d..a1b8de7 100644 --- a/tests/auto/qmap/tst_qmap.cpp +++ b/tests/auto/qmap/tst_qmap.cpp @@ -837,6 +837,26 @@ void tst_QMap::qmultimap_specific() QVERIFY(i.key() == 9); QVERIFY(i.value() == 98); } + + { + QMultiMap map1; + map1.insert(42, 1); + map1.insert(10, 2); + map1.insert(48, 3); + QMultiMap map2; + map2.insert(8, 4); + map2.insert(42, 5); + map2.insert(95, 12); + + map1+=map2; + map2.insert(42, 1); + map2.insert(10, 2); + map2.insert(48, 3); + QCOMPARE(map1.count(), map2.count()); + QVERIFY(map1.remove(42,5)); + QVERIFY(map2.remove(42,5)); + QVERIFY(map1 == map2); + } } QTEST_APPLESS_MAIN(tst_QMap) -- cgit v0.12