diff options
Diffstat (limited to 'src/corelib/global/qglobal.h')
-rw-r--r-- | src/corelib/global/qglobal.h | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index d32f1b420c..fc85bec962 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1065,29 +1065,12 @@ QForeachContainer<typename std::decay<T>::type> qMakeForeachContainer(T &&t) } -#if __cplusplus >= 201703L // Use C++17 if statement with initializer. User's code ends up in a else so // scoping of different ifs is not broken #define Q_FOREACH(variable, container) \ for (auto _container_ = QtPrivate::qMakeForeachContainer(container); \ _container_.i != _container_.e; ++_container_.i) \ if (variable = *_container_.i; false) {} else -#else -// Explanation of the control word: -// - it's initialized to 1 -// - that means both the inner and outer loops start -// - if there were no breaks, at the end of the inner loop, it's set to 0, which -// causes it to exit (the inner loop is run exactly once) -// - at the end of the outer loop, it's inverted, so it becomes 1 again, allowing -// the outer loop to continue executing -// - if there was a break inside the inner loop, it will exit with control still -// set to 1; in that case, the outer loop will invert it to 0 and will exit too -#define Q_FOREACH(variable, container) \ -for (auto _container_ = QtPrivate::qMakeForeachContainer(container); \ - _container_.control && _container_.i != _container_.e; \ - ++_container_.i, _container_.control ^= 1) \ - for (variable = *_container_.i; _container_.control; _container_.control = 0) -#endif #endif // QT_NO_FOREACH #define Q_FOREVER for(;;) |