From 02578ba03d87e75a1ae501938e7edb7c391d8c64 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 5 Oct 2022 15:38:44 +0200 Subject: [PATCH] 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 Reviewed-by: Thiago Macieira --- src/corelib/global/qforeach.h | 20 +------------------- 1 file changed, 1 insertion(+), 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 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