From 155ee2bbd7ef645d82aada3df7b4ef817ea0a5f8 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 20 Oct 2020 18:23:46 +0200 Subject: [PATCH] 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 --- src/corelib/tools/qlist.h | 10 +++++----- src/corelib/tools/qvarlengtharray.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 38cc0ed348e..40ee923cd41 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(this); } public: - template + template qsizetype indexOf(const AT &t, qsizetype from = 0) const noexcept; - template + template qsizetype lastIndexOf(const AT &t, qsizetype from = -1) const noexcept; - template + template 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 + template 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 + template bool removeOne(const AT &t) { const qsizetype i = indexOf(t); diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index d7e19415396..0bbee4f36e7 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -190,11 +190,11 @@ public: inline qsizetype capacity() const { return a; } inline void reserve(qsizetype size); - template + template inline qsizetype indexOf(const AT &t, qsizetype from = 0) const; - template + template inline qsizetype lastIndexOf(const AT &t, qsizetype from = -1) const; - template + template inline bool contains(const AT &t) const; inline T &operator[](qsizetype idx)