Coding style: Remove outdated recommendation of foreach()

Change-Id: I01eadfdbefededf3b71df492a0e29abdd3a3a93f
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2020-12-04 17:43:58 +01:00
parent 1d9be08e90
commit 7e8c212c1a

View File

@@ -202,35 +202,6 @@
}
\endcode
\li You can use the Qt \c foreach loop in non-time-critical code with a Qt
container. It is a nice way to keep line noise down and to give the
loop variable a proper name:
\code
foreach (QWidget *widget, container)
doSomething(widget);
-NOT-
Container::iterator end = container.end();
for (Container::iterator it = container.begin(); it != end; ++it)
doSomething(*it);
\endcode
Make the loop variable const, if possible. This might prevent
unnecessary detaching of shared data:
\code
foreach (const QString &name, someListOfNames)
doSomething(name);
- NOT -
foreach (QString name, someListOfNames)
doSomething(name);
\endcode
\endlist
\section1 Formatting