| 1 |
// P2589R1 |
| 2 |
// { dg-do run { target c++23 } } |
| 3 |
|
| 4 |
extern "C" void abort (); |
| 5 |
|
| 6 |
struct S |
| 7 |
{ |
| 8 |
S () {}; |
| 9 |
static int &operator[] () { return a[0]; } |
| 10 |
static int &operator[] (int x) { return a[x]; } |
| 11 |
static int &operator[] (int x, long y) { return a[x + y * 8]; } |
| 12 |
static int a[64]; |
| 13 |
}; |
| 14 |
int S::a[64]; |
| 15 |
|
| 16 |
int |
| 17 |
main () |
| 18 |
{ |
| 19 |
S s; |
| 20 |
for (int i = 0; i < 64; i++) |
| 21 |
s.a[i] = 64 - i; |
| 22 |
if (s[] != 64 || s[3] != 61 || s[4, 5] != 20) |
| 23 |
abort (); |
| 24 |
s[]++; |
| 25 |
s[42]++; |
| 26 |
++s[3, 2]; |
| 27 |
if (s.a[0] != 65 || s.a[42] != 23 || s.a[19] != 46) |
| 28 |
abort (); |
| 29 |
} |