Debian Codegraph @

gcc/testsuite/g++.dg/cpp23/explicit-obj-ops-mem-subscript.C

raw
1 // P0847R7
2 // { dg-do compile { target c++23 } }
3
4 // uses of member only operators (subscript)
5
6 // execution paths for subscript with 1 argument and 0 and 2+ arguments are different
7 // therefore we should additionally test the 0 and 2 argument cases as well
8
9 struct S {
10 void operator[](this S&) {}
11 void operator[](this S&, int) {}
12 void operator[](this S&, int, int) {}
13 template<typename... Args>
14 void operator[](this S&, Args... args) {}
15 };
16
17 void non_dep()
18 {
19 S s{};
20 s[];
21 s[0];
22 s[0, 0];
23 s[0, 0, 0];
24 }
25
26 template<typename = void>
27 void dependent()
28 {
29 S s{};
30 s[];
31 s[0];
32 s[0, 0];
33 s[0, 0, 0];
34 }
35
36 void call()
37 {
38 dependent();
39 }
40