aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp23/explicit-obj-ops-mem-subscript.C
blob: 3eb003062c092d8b7f7d7500411d26634b6f5380 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// P0847R7
// { dg-do compile { target c++23 } }

// uses of member only operators (subscript)

// execution paths for subscript with 1 argument and 0 and 2+ arguments are different
// therefore we should additionally test the 0 and 2 argument cases as well

struct S {
  void operator[](this S&) {}
  void operator[](this S&, int) {}
  void operator[](this S&, int, int) {}
  template<typename... Args>
  void operator[](this S&, Args... args) {}
};

void non_dep()
{
  S s{};
  s[];
  s[0];
  s[0, 0];
  s[0, 0, 0];
}

template<typename = void>
void dependent()
{
  S s{};
  s[];
  s[0];
  s[0, 0];
  s[0, 0, 0];
}

void call()
{
  dependent();
}