| 1 |
// PR c++/123667 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "" } |
| 4 |
|
| 5 |
namespace std { |
| 6 |
template <typename T> struct tuple_size; |
| 7 |
template <int, typename> struct tuple_element; |
| 8 |
} |
| 9 |
|
| 10 |
struct A { |
| 11 |
int i; |
| 12 |
template <int I> int &get () { return i; } |
| 13 |
}; |
| 14 |
|
| 15 |
template <> struct std::tuple_size <A> { static const int value = 2; }; |
| 16 |
template <int I> struct std::tuple_element <I,A> { using type = int; }; |
| 17 |
|
| 18 |
auto [ x, y ] = A { 0 }; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 19 |
|
| 20 |
template <int N> |
| 21 |
void |
| 22 |
foo () |
| 23 |
{ |
| 24 |
using a = decltype (x); |
| 25 |
auto [ x, y ] = A { 0 }; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 26 |
using b = decltype (x); |
| 27 |
} |
| 28 |
|
| 29 |
void |
| 30 |
bar () |
| 31 |
{ |
| 32 |
foo <42> (); |
| 33 |
} |