| 1 |
// P2662R3 - Pack Indexing |
| 2 |
// PR c++/113798 |
| 3 |
// { dg-do compile { target c++26 } } |
| 4 |
// From LLVM's cxx2c-pack-indexing.cpp. |
| 5 |
|
| 6 |
template<typename...> |
| 7 |
struct X { }; |
| 8 |
|
| 9 |
template<typename... T> |
| 10 |
requires requires(T...[0]) { {T...[0](0)}; } |
| 11 |
struct S : T...[1] { |
| 12 |
[[maybe_unused]] T...[1] base = {}; |
| 13 |
using foo = T...[1]; |
| 14 |
S() : T...[1]() { } |
| 15 |
X<T...[0]> x; |
| 16 |
const T...[0] f(T...[0]&& parm) noexcept((T...[0])0) { |
| 17 |
T...[0] (*test)(const volatile T...[0]**); |
| 18 |
thread_local T...[0] d; |
| 19 |
[[maybe_unused]] T...[0] a = parm; |
| 20 |
auto ptr = new T...[0](0); |
| 21 |
(*ptr).~T...[0](); |
| 22 |
return T...[0](0); |
| 23 |
typename T...[1]::foo b = 0; |
| 24 |
T...[1]::i = 0; |
| 25 |
return (T...[0])(a); |
| 26 |
new T...[0]; |
| 27 |
[[maybe_unused]] auto l = []<T...[0]>(T...[0][1]) -> T...[0]{ return {}; }; |
| 28 |
[[maybe_unused]] auto _ = l.template operator()<T...[0]{}>({0}); |
| 29 |
} |
| 30 |
operator T...[0]() const { } |
| 31 |
}; |
| 32 |
|
| 33 |
struct base { |
| 34 |
using foo = int; |
| 35 |
static inline int i = 42; |
| 36 |
}; |
| 37 |
|
| 38 |
int main() |
| 39 |
{ |
| 40 |
S<int, base>().f(0); |
| 41 |
} |