Debian Codegraph @

gcc/testsuite/g++.dg/modules/lambda-7.h

raw
1 struct S {
2 int (*a)(int) = [](int x) { return x * 2; };
3
4 int b(int x, int (*f)(int) = [](int x) { return x * 3; }) {
5 return f(x);
6 }
7
8 static int c(int x, int (*f)(int) = [](int x) { return x * 4; }) {
9 return f(x);
10 }
11 };
12
13 // this is an ODR violation to include this header in multiple TUs
14 // (the lambda is a different type in each TU, see [basic.def.odr] p15.6);
15 // keep the check that we can emit the lambda from a header unit,
16 // but skip it when checking ODR deduplication.
17 #ifndef CHECK_ODR_VIOLATIONS
18 inline int d(int x, int (*f)(int) = [](int x) { return x * 5; }) {
19 return f(x);
20 }
21 #endif
22
23 // unevaluated lambdas
24 #if __cplusplus >= 202002L
25 struct E : decltype([](int x) { return x * 6; }) {
26 decltype([](int x) { return x * 7; }) f;
27 };
28
29 template <typename T>
30 struct G : decltype([](int x) { return x * 8; }) {
31 decltype([](int x) { return x * 9; }) h;
32 };
33
34 template <>
35 struct G<double> : decltype([](int x) { return x * 10; }) {
36 decltype([](int x) { return x * 11; }) i;
37 };
38 #endif
39
40 // concepts
41 #if __cpp_concepts >= 201907L
42 template <typename T>
43 concept J = requires { []{ T(); }; };
44
45 template <typename T>
46 concept K = []{ return sizeof(T) == 1; }();
47 #endif
48