]> gcc.gnu.org Git - gcc.git/blob - gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const.C
merge in cxx0x-lambdas-branch@152308
[gcc.git] / gcc / testsuite / g++.dg / cpp0x / lambda / lambda-const.C
1 // { dg-do "run" }
2 // { dg-options "-std=c++0x" }
3
4 #include <cassert>
5
6 template<typename F>
7 void call(const F& f) { f(); }
8
9 int main() {
10 call([] () -> void {});
11 //call([] () mutable -> void {}); // { dg-error: "`f' does not have const `operator()'" }
12
13 int i = -1;
14 call([&i] () -> void { i = 0; });
15 assert(i == 0);
16 //call([i] () -> void { i = 0; }); // { dg-error: "assignment to non-reference capture in const lambda" }
17
18 return 0;
19 }
20
This page took 0.038664 seconds and 5 git commands to generate.