| 1 |
// { dg-do compile { target c++17 } } |
| 2 |
|
| 3 |
namespace std { |
| 4 |
template<typename T> struct tuple_size; |
| 5 |
template<int, typename> struct tuple_element; |
| 6 |
} |
| 7 |
|
| 8 |
struct A1 { int i,j; } a1; |
| 9 |
template<> struct std::tuple_size<A1> { }; |
| 10 |
void f1() { auto [ x ] = a1; } // { dg-error "only 1 name provided" } |
| 11 |
|
| 12 |
struct A2 { int i,j; } a2; |
| 13 |
template<> struct std::tuple_size<A2> { enum { value = 5 }; }; |
| 14 |
void f2() { auto [ x ] = a2; } // { dg-error "only 1 name provided" } |
| 15 |
// { dg-message "decomposes into 5" "" { target *-*-* } .-1 } |
| 16 |
|
| 17 |
struct A3 { int i,j; } a3; |
| 18 |
template<> struct std::tuple_size<A3> { enum { value = 1 }; }; |
| 19 |
void f3() { auto [ x ] = a3; } // { dg-error "get" } |
| 20 |
|
| 21 |
struct A3a { int i,j; int get(); } a3a; |
| 22 |
template<> struct std::tuple_size<A3a> { enum { value = 1 }; }; |
| 23 |
void f3a() { auto [ x ] = a3a; } // { dg-error "get" } |
| 24 |
|
| 25 |
struct A3b { int i,j; } a3b; |
| 26 |
int get(A3b&&); |
| 27 |
template<> struct std::tuple_size<A3b> { enum { value = 1 }; }; |
| 28 |
void f3b() { auto [ x ] = a3b; } // { dg-error "get<0>" } |
| 29 |
|
| 30 |
struct A4 { |
| 31 |
int ar[3]; |
| 32 |
template <int I> int& get() { return ar[I]; } |
| 33 |
} a4; |
| 34 |
template<> struct std::tuple_size<A4> { enum { value = 3 }; }; |
| 35 |
void f4() { auto [ x, y, z ] = a4; } // { dg-error "tuple_element" } |
| 36 |
|
| 37 |
struct A5 { } a5; |
| 38 |
template <int I> int& get(A5&& a); |
| 39 |
template<> struct std::tuple_size<A5> { enum { value = 3 }; }; |
| 40 |
void f5() { auto [ x, y, z ] = a5; } // { dg-error "tuple_element" } |
| 41 |
|
| 42 |
struct A6 { } a6; |
| 43 |
template <int I> int& get(A6&& a); |
| 44 |
template<> struct std::tuple_size<A6> { enum { value = 3 }; }; |
| 45 |
template<> struct std::tuple_element<0, A6> { }; |
| 46 |
void f6() { auto [ x, y, z ] = a6; } // { dg-error "no type named .type" } |