Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/decomp1-aux.cc

raw
1 // P1091R3
2 // { dg-do compile { target { c++17 && c++14_down } } }
3
4 namespace std {
5 template<typename T> struct tuple_size;
6 template<int, typename> struct tuple_element;
7 }
8
9 struct A {
10 int i;
11 A(int x) : i(x) {}
12 template <int I> int& get() { return i; }
13 };
14 struct B { int a, b, c; };
15
16 template<> struct std::tuple_size<A> { static const int value = 2; };
17 template<int I> struct std::tuple_element<I,A> { using type = int; };
18
19 B s = { 1, 2, 3 };
20
21 #line 1
22 static auto [ d, e, f ] = s;
23 static auto [ g, h ] = A (42);
24
25 int &
26 foo (int x)
27 {
28 switch (x)
29 {
30 case 0: return d;
31 case 1: return e;
32 case 2: return f;
33 case 3: return g;
34 default: return h;
35 }
36 }
37
38 int
39 bar (int x)
40 {
41 #line 3
42 static auto [ m, n, o ] = s;
43 static auto [ p, q ] = A (43);
44 switch (x)
45 {
46 case 0: return ++m;
47 case 1: return ++n;
48 case 2: return ++o;
49 case 3: return ++p;
50 default: return ++q;
51 }
52 }