diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-10-20 18:23:46 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-10-23 16:37:14 +0200 |
commit | 155ee2bbd7ef645d82aada3df7b4ef817ea0a5f8 (patch) | |
tree | 69d4dd70e3aaf5a89997c088ec1e3068576e8623 /src/corelib/tools/qlist.h | |
parent | 45cf0cf5135e653baaf689f51b3c6338d848c16e (diff) |
QList/QVLA: default the parameter for indexOf/contains/remove/etc.
This allows to use list-initialization when calling these functions,
for instance list.removeAll({}).
Change-Id: I2828d900a44bd0bc5aea5fba4777304b09190bc9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qlist.h')
-rw-r--r-- | src/corelib/tools/qlist.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 38cc0ed348..40ee923cd4 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -68,12 +68,12 @@ protected: const Self *self() const { return static_cast<const Self *>(this); } public: - template <typename AT> + template <typename AT = T> qsizetype indexOf(const AT &t, qsizetype from = 0) const noexcept; - template <typename AT> + template <typename AT = T> qsizetype lastIndexOf(const AT &t, qsizetype from = -1) const noexcept; - template <typename AT> + template <typename AT = T> bool contains(const AT &t) const noexcept { return self()->indexOf(t) != -1; @@ -360,7 +360,7 @@ public: // QList compatibility void removeAt(qsizetype i) { remove(i); } - template <typename AT> + template <typename AT = T> qsizetype removeAll(const AT &t) { const const_iterator ce = this->cend(), cit = std::find(this->cbegin(), ce, t); @@ -381,7 +381,7 @@ public: erase(it, e); return result; } - template <typename AT> + template <typename AT = T> bool removeOne(const AT &t) { const qsizetype i = indexOf(t); |