Details
-
Suggestion
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
5.5.1, 5.6
-
None
-
All
Description
Current foreach loop iterates over copy of container. This add some small overhead for Qt-containers and makes full container copy for stl containers which is error prone to 1) change of container type or 2) misunderstanding/not-awareness of how foreach works.
So generally this can be alternative for current foreach which will work good with Qt and std container.
Current foreach can be helpful only if some signal-slot calls (which can change the container) happens inside loop. But I think it is better to clearly write such loops ... I mean straightly showing of making of container copy and iterating over it (so that misunderstandings like here:
https://codereview.qt-project.org/#/c/115389/1/src/widgets/accessible/complexwidgets.cpp
will never happens).
The code which is already written and work with foreach should continue to work so it is only possible to add another macro for constant reference to containers loops.