1 // Generic lambda type dependence test part from N3690 5.1.2.12
2 // { dg-do compile { target c++14 } }
3 // { dg-options "-pedantic" }
4 
5 void f(int, const int (&)[2] = {}) { } // #1
f(const int &,const int (&)[1])6 void f(const int&, const int (&)[1]) { } // #2
7 
test()8 void test()
9 {
10   const int x = 17;
11   auto g = [](auto a) {
12     f(x); // OK: calls #1, does not capture x
13   };
14   auto g2 = [=](auto a) {
15     int selector[sizeof(a) == 1 ? 1 : 2]{};
16     f(x, selector); // OK: is a dependent expression, so captures x
17   };
18 }
19 
20 struct S {
21   struct N {
testS::N22     auto test () { return 7.f; }
23   };
24 };
25 
26 #include <utility>
27 
main()28 int main()
29 {
30   auto f = [] <typename T> (T const& s) mutable {	// { dg-warning "lambda templates are only available with" "" { target c++17_down } }
31     typename T::N x;
32     return x.test ();
33   };
34   auto g = [] (auto const& s) {
35     typename std::decay<decltype (s)>::type::N x;
36     return x.test ();
37   };
38 
39   S i;
40   f(i);
41   g(i);
42 }
43 
44