Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template.C

raw
1 // { dg-do run { target c++11 } }
2
3 extern "C" void abort();
4
5 template <class T>
6 auto apply (T t) -> decltype (t())
7 {
8 return t();
9 }
10
11 template <class T>
12 void f(T t)
13 {
14 T t2 = t;
15 if (t != [=]()->T { return t; }())
16 abort ();
17 if (t != [=] { return t; }())
18 abort ();
19 if (t != [=] { return t2; }())
20 abort ();
21 if (t != [&] { return t; }())
22 abort ();
23 if (t != apply([=]{return t;}))
24 abort ();
25
26 int i;
27 [&] (int a) { return a+i+t; } (0);
28 [&] (int a) -> decltype(a) { return a+i+t; } (0);
29 [&] (int a) -> decltype(i) { return a+i+t; } (0);
30 [&] (int a) -> decltype(t) { return a+i+t; } (0);
31 [&] (int a) -> decltype(a+i) { return a+i+t; } (0);
32 [&] (int a) -> decltype(a+t) { return a+i+t; } (0);
33 [&] (int a) -> decltype(i+t) { return a+i+t; } (0);
34 [&] (int a) -> decltype(a+i+t) { return a+i+t; } (0);
35 }
36
37 int main()
38 {
39 f(0xbeef);
40 }