Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/concepts-placeholder7.C

raw
1 // PR c++/99899
2 // { dg-do compile { target c++20 } }
3
4 template <class T> concept C1 = sizeof(T) > sizeof(int[1]);
5
6 template <class>
7 void f() {
8 int x[] = {1,2};
9 int y[] = {3};
10 C1 auto [a,b] = x; // { dg-error "structured binding declaration cannot have constrained 'auto' type 'auto \\\[requires ::C1<<placeholder>, >\\\]'" }
11 C1 auto [c] = y; // { dg-error "structured binding declaration cannot have constrained 'auto' type 'auto \\\[requires ::C1<<placeholder>, >\\\]'" }
12 // { dg-error "constraints" "" { target *-*-* } .-1 }
13 }
14
15 template <class T>
16 void g() {
17 T x[] = {1,2};
18 T y[] = {3};
19 C1 auto [a,b] = x; // { dg-error "structured binding declaration cannot have constrained 'auto' type 'auto \\\[requires ::C1<<placeholder>, >\\\]'" }
20 C1 auto [c] = y; // { dg-error "structured binding declaration cannot have constrained 'auto' type 'auto \\\[requires ::C1<<placeholder>, >\\\]'" }
21 // { dg-error "constraints" "" { target *-*-* } .-1 }
22 }
23 template void g<int>();
24
25
26 template <class... Ts> concept C2 = sizeof...(Ts) > 1;
27
28 struct S { int a, b; } s;
29
30 template <class T>
31 void h() {
32 const C2<T> auto& [a, b] = s; // { dg-error "structured binding declaration cannot have constrained 'auto' type 'const auto \\\[requires ::C2<<placeholder>, >\\\]'" }
33 }
34 template void h<int>();