diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-10-05 15:38:44 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-10-06 11:47:39 +0200 |
commit | 02578ba03d87e75a1ae501938e7edb7c391d8c64 (patch) | |
tree | f9860977c0e9b8d9476bda5824b4426ac44d9fe4 | |
parent | d7cca67352c7e6ef69222b340b6488b48f8fae30 (diff) |
Q_FOREACH: code tidies
We can get rid of the `control` member variable since it's unused (after
the switch to C++17). We can also get rid of the move operations as we
can use guaranteed elision. Move operations have always been a bit
finicky in their definition, as they wouldn't carry over the logical
positions of the iterators (but would always reset them to begin/end).
Change-Id: I7971ea92c5c23e98ca8a4951b54c4ec8133eff1c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/global/qforeach.h | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/src/corelib/global/qforeach.h b/src/corelib/global/qforeach.h index 95d68f31e4..80d0c41aa2 100644 --- a/src/corelib/global/qforeach.h +++ b/src/corelib/global/qforeach.h @@ -21,31 +21,13 @@ namespace QtPrivate { template <typename T> class QForeachContainer { - Q_DISABLE_COPY(QForeachContainer) + Q_DISABLE_COPY_MOVE(QForeachContainer) public: QForeachContainer(const T &t) : c(t), i(qAsConst(c).begin()), e(qAsConst(c).end()) {} QForeachContainer(T &&t) : c(std::move(t)), i(qAsConst(c).begin()), e(qAsConst(c).end()) {} - QForeachContainer(QForeachContainer &&other) - : c(std::move(other.c)), - i(qAsConst(c).begin()), - e(qAsConst(c).end()), - control(std::move(other.control)) - { - } - - QForeachContainer &operator=(QForeachContainer &&other) - { - c = std::move(other.c); - i = qAsConst(c).begin(); - e = qAsConst(c).end(); - control = std::move(other.control); - return *this; - } - T c; typename T::const_iterator i, e; - int control = 1; }; // Containers that have a detach function are considered shared, and are OK in a foreach loop |