[Development] How to port from Q_FOREACH to range-based for

Olivier Goffart olivier at woboq.com
Tue Jun 11 09:35:49 CEST 2019


On 11.06.19 09:17, Lars Knoll wrote:
> So, is removing it worth all the hassle to us and our users? Q_FOREACH is a macro and it doesn’t really cost us anything to keep it around. Yes, it has issues with non Qt containers and I wouldn’t recommend it for any new code. But maybe we could simply fix that part, but making Q_FOREACH emit a compiler warning if used on a container that’s not implicitly shared?

+1
Although we should probably still discourage its usage in the documentation.

Regarding the compiler warning:
   https://codereview.qt-project.org/c/qt/qtbase/+/244010



More information about the Development mailing list