On 10/26/18 10:26 PM, Elvis Stansvik wrote:
For completely other reasons, I came across "Range-based for
statements with initializer" today:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0614r1.html
With that, the Qt best practice could become
for (const auto list = getQList(); const auto &v : list) {
...
}
Which may or may not be pretty, but avoids the extra line of code and
keeps the scope clean.
We could even wrap this in a macro for convenience. We would call that macro
'foreach' for example.
Ah no, wait, this name is already taken by a macro that does exactly that :-)
Jokes aside, I think we still should let users use Q_FOREACH for implicitly
shared containers.
--
Olivier
Woboq - Qt services and support - https://woboq.com - https://code.woboq.org
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development