| 1 |
// PR c++/96241 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
template <typename T, T...> struct S {}; |
| 5 |
template <typename T, T t> using U = S<T, __integer_pack(t)...>; |
| 6 |
template <long... N> using f = S<unsigned long, N...>; |
| 7 |
template <long N> using V = U<unsigned long, N>; |
| 8 |
template <int N> struct A { typedef int type[N]; }; |
| 9 |
template <int N> struct B { typename A<N>::type k; }; |
| 10 |
template <typename T, int N, unsigned long... P> |
| 11 |
constexpr B<N> bar(T (&arr)[N], f<P...>) { |
| 12 |
return {arr[P]...}; |
| 13 |
} |
| 14 |
template <typename T, int N> constexpr B<N> foo(T (&arr)[N]) { |
| 15 |
return bar(arr, V<N>{}); |
| 16 |
} |
| 17 |
constexpr char arr[2]{}; |
| 18 |
B<2> b = foo(arr); |