Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/lambda-deduce-mult.C

raw
1 // Testcase for an extension to allow return type deduction when the lambda
2 // contains more than just a single return-statement.
3
4 // { dg-do run { target c++14 } }
5
6 bool b;
7 template <class T>
8 T f (T t)
9 {
10 return [=] {
11 auto i = t+1;
12 if (b)
13 return i+1;
14 else
15 return i+1;
16 }();
17 }
18
19 int main()
20 {
21 // Pointless, but well-formed.
22 [] { return 1; return 2; }();
23
24 if (f(1) != 3)
25 return 1;
26 }