summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstringlist.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-10-16 16:15:02 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-10-23 16:37:14 +0200
commit45cf0cf5135e653baaf689f51b3c6338d848c16e (patch)
treeaae1539a0bed2e00667f19fb1d3b7ff1a53329ed /src/corelib/text/qstringlist.cpp
parentd53bbecf4c2565f2e5fd834b20ff90b073a25189 (diff)
QList: make (last)IndexOf and contains function templates
There's no reason why they shouldn't be; one might want to do a lookup passing an object which is comparable with the list's value type (e.g. search with a QByteArrayView needle into a QByteArrayList haystack). Insofar we've had to add overloads to QListSpecialMethods for all these cases, which clearly doesn't scale and creates top-tier and low-tier lists. There is one downside, namely, calling QList<A>::indexOf(B) for a B for which there isn't an operator==(A, B) but only a conversion towards A. Before, B was converted only once (at call site), now it's converted at every call of operator==. In general: such types are broken and should be fixed on their own. However let's avoid a possible regression in client code, so I've left the QString overloads in QStringList in. To get there: centralize the implementation of those methods in a empty base class, which gets then inherited by QListSpecialMethods, which is inherited by QList. This is there are still special methods that may want to overload contains, e.g. QStringList which also passes a case sensitivity). The only breakages comes from code that was already broken, for instance mixing signed and unsigned types, and the beauty of this is that now we *detect* that instead of silently ignoring. QVLA and other QList methods will be tackled in future commits. [ChangeLog][QtCore][QList] The indexOf, lastIndexOf and contains methods now take an object of any datatype -- and not just the list's own value type. This allows for heterogenous lookup in QLists. Change-Id: Ib34812217eb2b0f926fad1fc195b33758196941c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/text/qstringlist.cpp')
-rw-r--r--src/corelib/text/qstringlist.cpp49
1 files changed, 0 insertions, 49 deletions
diff --git a/src/corelib/text/qstringlist.cpp b/src/corelib/text/qstringlist.cpp
index 233f765355..c395750376 100644
--- a/src/corelib/text/qstringlist.cpp
+++ b/src/corelib/text/qstringlist.cpp
@@ -369,55 +369,6 @@ bool QtPrivate::QStringList_contains(const QStringList *that, QLatin1String str,
return stringList_contains(*that, str, cs);
}
-/*!
- \fn bool QStringList::indexOf(QStringView str, qsizetype from) const
- \overload
- \since 5.13
-
- Returns the index position of the first occurrence of \a str in
- the list, searching forward from index position \a from. Returns
- -1 if no item matched.
-
- \sa lastIndexOf(), contains()
- */
-
-/*!
- \fn bool QStringList::indexOf(QLatin1String str, qsizetype from) const
- \overload
- \since 5.13
-
- Returns the index position of the first occurrence of \a str in
- the list, searching forward from index position \a from. Returns
- -1 if no item matched.
-
- \sa lastIndexOf(), contains()
- */
-
-/*!
- \fn bool QStringList::lastIndexOf(QStringView str, qsizetype from) const
- \overload
- \since 5.13
-
- Returns the index position of the last occurrence of \a str in
- the list, searching backward from index position \a from. If \a
- from is -1 (the default), the search starts at the last item.
- Returns -1 if no item matched.
-
- \sa indexOf(), contains()
- */
-
-/*!
- \fn bool QStringList::lastIndexOf(QLatin1String str, qsizetype from) const
- \overload
- \since 5.13
-
- Returns the index position of the last occurrence of \a str in
- the list, searching backward from index position \a from. If \a
- from is -1 (the default), the search starts at the last item.
- Returns -1 if no item matched.
-
- \sa indexOf(), contains()
- */
#if QT_CONFIG(regularexpression)
/*!