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>
This commit is contained in:
parent
d7cca67352
commit
02578ba03d
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user