diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-12-03 10:33:46 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-12-04 00:16:57 +0100 |
| commit | bd04c5d7a4b907b8c4a2d2dda4ba3f24f687fb7f (patch) | |
| tree | 240de5511457122bc8b2d11e7fed1b5710a54107 | |
| parent | d149bd146c2551561bce4fe20e5c1d4f976a6ef6 (diff) | |
Remove operator[] from meta-association iterators
Most of them are not random access and operator[] makes no sense then.
Amends commit 8d359d61c16641d523e4189a7d473b6126b11011.
Change-Id: I724aaf98e14114d0fd1cb5bce5fdc2ed4690dae0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| -rw-r--r-- | src/corelib/kernel/qmetaassociation.cpp | 14 | ||||
| -rw-r--r-- | src/corelib/kernel/qmetaassociation.h | 7 | ||||
| -rw-r--r-- | src/corelib/kernel/qmetacontainer.h | 2 | ||||
| -rw-r--r-- | tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 9 |
4 files changed, 0 insertions, 32 deletions
diff --git a/src/corelib/kernel/qmetaassociation.cpp b/src/corelib/kernel/qmetaassociation.cpp index 7fbb356d9a0..5eae6658a57 100644 --- a/src/corelib/kernel/qmetaassociation.cpp +++ b/src/corelib/kernel/qmetaassociation.cpp @@ -464,13 +464,6 @@ QMetaType QMetaAssociation::mappedMetaType() const */ /*! - \fn QVariant::Reference<QMetaAssociation::Iterable::Iterator> QMetaAssociation::Iterable::Iterator::operator[](qsizetype n) const - Returns the item offset from the current one by \a n, converted to a - QVariant::Reference. The resulting QVariant::Reference resolves to the - mapped value if there is one, or to the key value if not. -*/ - -/*! \fn QVariant QMetaAssociation::Iterable::ConstIterator::key() const Returns the key this iterator points to. */ @@ -494,11 +487,4 @@ QMetaType QMetaAssociation::mappedMetaType() const iterator if there is one, or otherwise the key. */ -/*! - \fn QVariant QMetaAssociation::Iterable::ConstIterator::operator[](qsizetype n) const - Returns the item offset from the current one by \a n, converted to a - QVariant. The returned value is the mapped value at the current iterator if - there is one, or otherwise the key. -*/ - QT_END_NAMESPACE diff --git a/src/corelib/kernel/qmetaassociation.h b/src/corelib/kernel/qmetaassociation.h index d7b3fb65242..6d8de13e90a 100644 --- a/src/corelib/kernel/qmetaassociation.h +++ b/src/corelib/kernel/qmetaassociation.h @@ -41,7 +41,6 @@ public: reference operator*() const { return reference(*this); } pointer operator->() const { return pointer(*this); } - reference operator[](qsizetype n) const { return reference(*this + n); } }; class AssociativeConstIterator : public QConstIterator<QMetaAssociation> @@ -68,7 +67,6 @@ public: mapped_type operator*() const; pointer operator->() const { return pointer(*this); } - mapped_type operator[](qsizetype n) const; }; } // namespace QtMetaContainerPrivate @@ -126,11 +124,6 @@ inline AssociativeConstIterator::mapped_type AssociativeConstIterator::operator* return reference(*this); } -inline AssociativeConstIterator::mapped_type AssociativeConstIterator::operator[](qsizetype n) const -{ - return reference(*this + n); -} - class Association : public QIterable<QMetaAssociation> { public: diff --git a/src/corelib/kernel/qmetacontainer.h b/src/corelib/kernel/qmetacontainer.h index f8e73a8b0a2..c9d3a6bf9c6 100644 --- a/src/corelib/kernel/qmetacontainer.h +++ b/src/corelib/kernel/qmetacontainer.h @@ -1078,7 +1078,6 @@ public: QVariant::Reference<Iterator> operator*() const; QVariant::Pointer<Iterator> operator->() const; - QVariant::Reference<Iterator> operator[](qsizetype n) const; }; class ConstIterator : public QConstIterator<QMetaAssociation> @@ -1089,7 +1088,6 @@ public: QVariant operator*() const; QVariant::ConstPointer<ConstIterator> operator->() const; - QVariant operator[](qsizetype n) const; }; using RandomAccessIterator = Iterator; diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index d02cb5312d2..2fcfd056882 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -5319,10 +5319,6 @@ void tst_QVariant::iterateContainerElements() QMetaAssociation::Iterable::const_iterator end = iter.end(); QCOMPARE(*(++mapping.begin()), (*(it + 1)).toString()); - for (int i = 0, end = mapping.size(); i != end; ++i) { - QCOMPARE(*(std::next(mapping.begin(), i)), it[i].toString()); - } - for (int i = 0; it != end; ++it, ++i) { QCOMPARE(*(std::next(mapping.begin(), i)), (*it).toString()); } @@ -5415,11 +5411,6 @@ void tst_QVariant::modifyContainerElements() *(it + 1) = QStringLiteral("four"); QCOMPARE(*(++mapping.begin()), "four"); - for (int i = 0, end = mapping.size(); i != end; ++i) { - it[i] = QString::number(i); - QCOMPARE(*std::next(mapping.begin(), i), QString::number(i)); - } - for (int i = 0; it != end; ++it, ++i) { *it = QString::number(i + 10); QCOMPARE(*std::next(mapping.begin(), i), QString::number(i + 10)); |
