Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/lambda-targ7.C

raw
1 // PR c++/116567
2 // { dg-do compile { target c++20 } }
3
4 struct X { int n; };
5
6 template<auto N, auto F = []{ return N; }>
7 auto v1 = F;
8
9 template<auto N, auto F = [](auto y){ return decltype(N){N.n + y}; }>
10 auto v1g = F;
11
12 template<class T>
13 struct A {
14 template<auto N, auto F = []{ return N; }>
15 static inline auto v2 = F;
16
17 template<auto N, auto F = [](auto y){ return decltype(N){N.n + y}; }>
18 static inline auto v2g = F;
19
20 template<class U>
21 struct B {
22 template<auto N, auto F = []{ return N; }>
23 static inline auto v3 = F;
24
25 template<auto N, auto F = [](auto y){ return decltype(N){N.n + y}; }>
26 static inline auto v3g = F;
27
28 template<class V>
29 static void f() {
30 static_assert(v1<X{1}>().n == 1);
31 static_assert(v1g<X{1}>(42).n == 1 + 42);
32 static_assert(v2<X{2}>().n == 2);
33 static_assert(v2g<X{2}>(42).n == 2 + 42);
34 static_assert(v3<X{3}>().n == 3);
35 static_assert(v3g<X{3}>(42).n == 3 + 42);
36 }
37 };
38 };
39
40 int main() {
41 A<int>::B<int>::f<int>();
42 }