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