summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2016-11-09 17:37:52 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2016-12-10 18:11:38 +0000
commite5e26294f237d972122dd9d757956a8d7eea0294 (patch)
treee5e89f6dcb748b8909c5b2bd8f5369b898f9c6d7 /tests/auto/corelib/global/qglobal/tst_qglobal.cpp
parent4aebbef8ab94723d59679f30005b114197c995b9 (diff)
foreach: do not use operators that trigger non-evaluated contexts
Namely: decltype(). Ideally we'd want C++17's template constructor argument deduction, but instead use the C++11 solution: a factory function. This enables using things such as lambdas in the container argument. Change-Id: Idba64d8069d15bbafe54cfdebe24b1fba1eb8d0a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/global/qglobal/tst_qglobal.cpp')
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index bb6ec1c8e7..083526fdc4 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -102,6 +102,13 @@ void tst_QGlobal::for_each()
QCOMPARE(i, counter++);
}
QCOMPARE(counter, list.count());
+
+ // check whether we can use a lambda
+ counter = 0;
+ foreach (int i, [&](){ return list; }()) {
+ QCOMPARE(i, counter++);
+ }
+ QCOMPARE(counter, list.count());
}
void tst_QGlobal::qassert()