Debian Codegraph @

gcc/testsuite/g++.dg/cpp23/explicit-obj-basic4.C

raw
1 // P0847R7
2 // { dg-do compile { target c++23 } }
3
4 // valid overloading of iobj member functions without ref qualifiers
5 // with xobj member functions (and vice-versa)
6
7 // this is the most you can mix these, it may look short but it does test
8 // all allowed cases (other than by-value and unrelated types)
9
10 // [over.match.funcs.general.4]
11 // For implicit object member functions, the type of the implicit
12 // object parameter is
13 // -- “lvalue reference to cv X” for functions declared
14 // without a ref-qualifier or with the & ref-qualifier
15 // -- “rvalue reference to cv X” for functions declared with
16 // the && ref-qualifier
17
18 // [basic.scope.scope.3]
19 // Two non-static member functions have corresponding object
20 // parameters if:
21 // -- exactly one is an implicit object member function with no
22 // ref-qualifier and the types of their object parameters
23 // ([dcl.fct]), after removing top-level references, are the
24 // same, or
25
26 // in simpler terms, only the cv qualification of the explicit/implicit object
27 // parameter matter for determining whether these are redeclarations or overloads
28 // (when a ref qualifier is not present on the iobj member function)
29
30 // xobj first, iobj last
31
32 struct S0 {
33 void f(this S0 &);
34 void f(this S0 &&);
35 void f() const;
36 void f() volatile;
37 void f() const volatile;
38
39 void fc(this S0 const&);
40 void fc(this S0 const&&);
41 void fc();
42 void fc() volatile;
43 void fc() const volatile;
44
45 void fv(this S0 volatile&);
46 void fv(this S0 volatile&&);
47 void fv();
48 void fv() const;
49 void fv() const volatile;
50
51 void fcv(this S0 const volatile&);
52 void fcv(this S0 const volatile&&);
53 void fcv();
54 void fcv() const;
55 void fcv() volatile;
56 };
57
58 // iobj first, xobj last
59
60 struct S1 {
61 void f() const;
62 void f() volatile;
63 void f() const volatile;
64 void f(this S1 &);
65 void f(this S1 &&);
66
67 void fc();
68 void fc() volatile;
69 void fc() const volatile;
70 void fc(this S1 const&);
71 void fc(this S1 const&&);
72
73 void fv();
74 void fv() const;
75 void fv() const volatile;
76 void fv(this S1 volatile&);
77 void fv(this S1 volatile&&);
78
79 void fcv();
80 void fcv() const;
81 void fcv() volatile;
82 void fcv(this S1 const volatile&);
83 void fcv(this S1 const volatile&&);
84 };
85
86 // in order
87
88 struct S2 {
89 void f(this S2 &);
90 void f(this S2 &&);
91 void f() const;
92 void f() volatile;
93 void f() const volatile;
94
95 void fc();
96 void fc(this S2 const&);
97 void fc(this S2 const&&);
98 void fc() volatile;
99 void fc() const volatile;
100
101 void fv();
102 void fv() const;
103 void fv(this S2 volatile&);
104 void fv(this S2 volatile&&);
105 void fv() const volatile;
106
107 void fcv();
108 void fcv() const;
109 void fcv() volatile;
110 void fcv(this S2 const volatile&);
111 void fcv(this S2 const volatile&&);
112 };
113