From 05acc167c968722bf178c17710ff34b74d9cb124 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 8 Sep 2020 14:44:32 +0200 Subject: [PATCH] Remove pre-C++17 code path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iaa7f677f45cee50f0b9ed236cf5bef18d5764bfa Reviewed-by: MÃ¥rten Nordheim --- src/corelib/global/qglobal.h | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index d32f1b420c6..fc85bec9628 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1065,29 +1065,12 @@ QForeachContainer::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(;;)