tmp/tmp863x3wte/{from.md → to.md}
RENAMED
|
@@ -24,63 +24,80 @@ If the function selected by overload resolution is an implicit object
|
|
| 24 |
member function, the program is ill-formed.
|
| 25 |
|
| 26 |
[*Note 2*: The resolution of the address of an overload set in other
|
| 27 |
contexts is described in [[over.over]]. — *end note*]
|
| 28 |
|
| 29 |
-
##### Call to
|
| 30 |
|
| 31 |
Of interest in [[over.call.func]] are only those function calls in
|
| 32 |
-
which the *postfix-expression* ultimately contains an *id-expression*
|
| 33 |
-
that
|
| 34 |
-
nested arbitrarily deep in parentheses,
|
|
|
|
| 35 |
|
| 36 |
``` bnf
|
| 37 |
postfix-expression:
|
| 38 |
postfix-expression '.' id-expression
|
|
|
|
| 39 |
postfix-expression '->' id-expression
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
```
|
| 42 |
|
| 43 |
These represent two syntactic subcategories of function calls: qualified
|
| 44 |
function calls and unqualified function calls.
|
| 45 |
|
| 46 |
-
In qualified function calls, the function is
|
| 47 |
-
preceded by an `->` or `.`
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
[[over]] assumes that the
|
| 52 |
-
|
|
|
|
| 53 |
|
| 54 |
-
The
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
the
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
In unqualified function calls, the function is
|
| 61 |
-
*
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
*
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
|
| 74 |
-
if
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
[*Example 1*:
|
| 78 |
|
| 79 |
``` cpp
|
| 80 |
struct C {
|
| 81 |
-
|
| 82 |
void b() {
|
| 83 |
a(); // OK, (*this).a()
|
| 84 |
}
|
| 85 |
|
| 86 |
void c(this const C&); // #1
|
|
@@ -113,10 +130,19 @@ void d() {
|
|
| 113 |
void k(this int);
|
| 114 |
operator int() const;
|
| 115 |
void m(this const C& c) {
|
| 116 |
c.k(); // OK
|
| 117 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
};
|
| 119 |
```
|
| 120 |
|
| 121 |
— *end example*]
|
| 122 |
|
|
@@ -143,11 +169,11 @@ returning `R`”, or the type “reference to function of (`P₁`, …, `Pₙ`)
|
|
| 143 |
returning `R`”, a *surrogate call function* with the unique name
|
| 144 |
*call-function* and having the form
|
| 145 |
|
| 146 |
``` bnf
|
| 147 |
'R' *call-function* '(' conversion-type-id \ %
|
| 148 |
-
'F, P₁ a₁, …, Pₙ aₙ)' '{ return F (a₁, …, aₙ); }'
|
| 149 |
```
|
| 150 |
|
| 151 |
is also considered as a candidate function. Similarly, surrogate call
|
| 152 |
functions are added to the set of candidate functions for each
|
| 153 |
non-explicit conversion function declared in a base class of `T`
|
|
|
|
| 24 |
member function, the program is ill-formed.
|
| 25 |
|
| 26 |
[*Note 2*: The resolution of the address of an overload set in other
|
| 27 |
contexts is described in [[over.over]]. — *end note*]
|
| 28 |
|
| 29 |
+
##### Call to designated function <a id="over.call.func">[[over.call.func]]</a>
|
| 30 |
|
| 31 |
Of interest in [[over.call.func]] are only those function calls in
|
| 32 |
+
which the *postfix-expression* ultimately contains an *id-expression* or
|
| 33 |
+
*splice-expression* that designates one or more functions. Such a
|
| 34 |
+
*postfix-expression*, perhaps nested arbitrarily deep in parentheses,
|
| 35 |
+
has one of the following forms:
|
| 36 |
|
| 37 |
``` bnf
|
| 38 |
postfix-expression:
|
| 39 |
postfix-expression '.' id-expression
|
| 40 |
+
postfix-expression '.' splice-expression
|
| 41 |
postfix-expression '->' id-expression
|
| 42 |
+
postfix-expression '->' splice-expression
|
| 43 |
+
id-expression
|
| 44 |
+
splice-expression
|
| 45 |
```
|
| 46 |
|
| 47 |
These represent two syntactic subcategories of function calls: qualified
|
| 48 |
function calls and unqualified function calls.
|
| 49 |
|
| 50 |
+
In qualified function calls, the function is designated by an
|
| 51 |
+
*id-expression* or *splice-expression* E preceded by an `->` or `.`
|
| 52 |
+
operator. Since the construct `A->B` is generally equivalent to
|
| 53 |
+
`(*A).B`, the rest of [[over]] assumes, without loss of generality, that
|
| 54 |
+
all member function calls have been normalized to the form that uses an
|
| 55 |
+
object and the `.` operator. Furthermore, [[over]] assumes that the
|
| 56 |
+
*postfix-expression* that is the left operand of the `.` operator has
|
| 57 |
+
type “cv `T`” where `T` denotes a class.[^2]
|
| 58 |
|
| 59 |
+
The set of candidate functions either is the set found by name lookup
|
| 60 |
+
[[class.member.lookup]] if E is an *id-expression* or is the set
|
| 61 |
+
determined as specified in [[expr.prim.splice]] if E is a
|
| 62 |
+
*splice-expression*. The argument list is the *expression-list* in the
|
| 63 |
+
call augmented by the addition of the left operand of the `.` operator
|
| 64 |
+
in the normalized member function call as the implied object argument
|
| 65 |
+
[[over.match.funcs]].
|
| 66 |
|
| 67 |
+
In unqualified function calls, the function is designated by an
|
| 68 |
+
*id-expression* or a *splice-expression* E. The set of candidate
|
| 69 |
+
functions either is the set found by name lookup [[basic.lookup]] if E
|
| 70 |
+
is an *id-expression* or is the set determined as specified in
|
| 71 |
+
[[expr.prim.splice]] if E is a *splice-expression*. The set of candidate
|
| 72 |
+
functions consists either entirely of non-member functions or entirely
|
| 73 |
+
of member functions of some class `T`. In the former case or if E is
|
| 74 |
+
either a *splice-expression* or the address of an overload set, the
|
| 75 |
+
argument list is the same as the *expression-list* in the call.
|
| 76 |
+
Otherwise, the argument list is the *expression-list* in the call
|
| 77 |
+
augmented by the addition of an implied object argument as in a
|
| 78 |
+
qualified function call. If the current class is, or is derived from,
|
| 79 |
+
`T`, and the keyword `this` [[expr.prim.this]] refers to it,
|
| 80 |
|
| 81 |
+
- if the unqualified function call appears in a precondition assertion
|
| 82 |
+
of a constructor or a postcondition assertion of a destructor and
|
| 83 |
+
overload resolution selects a non-static member function, the call is
|
| 84 |
+
ill-formed;
|
| 85 |
+
- otherwise, the implied object argument is `(*this)`.
|
| 86 |
+
|
| 87 |
+
Otherwise,
|
| 88 |
+
|
| 89 |
+
- if overload resolution selects a non-static member function, the call
|
| 90 |
+
is ill-formed;
|
| 91 |
+
- otherwise, a contrived object of type `T` becomes the implied object
|
| 92 |
+
argument.[^3]
|
| 93 |
|
| 94 |
[*Example 1*:
|
| 95 |
|
| 96 |
``` cpp
|
| 97 |
struct C {
|
| 98 |
+
bool a();
|
| 99 |
void b() {
|
| 100 |
a(); // OK, (*this).a()
|
| 101 |
}
|
| 102 |
|
| 103 |
void c(this const C&); // #1
|
|
|
|
| 130 |
void k(this int);
|
| 131 |
operator int() const;
|
| 132 |
void m(this const C& c) {
|
| 133 |
c.k(); // OK
|
| 134 |
}
|
| 135 |
+
|
| 136 |
+
C()
|
| 137 |
+
pre(a()) // error: implied this in constructor precondition
|
| 138 |
+
pre(this->a()) // OK
|
| 139 |
+
post(a()); // OK
|
| 140 |
+
~C()
|
| 141 |
+
pre(a()) // OK
|
| 142 |
+
post(a()) // error: implied this in destructor postcondition
|
| 143 |
+
post(this->a()); // OK
|
| 144 |
};
|
| 145 |
```
|
| 146 |
|
| 147 |
— *end example*]
|
| 148 |
|
|
|
|
| 169 |
returning `R`”, a *surrogate call function* with the unique name
|
| 170 |
*call-function* and having the form
|
| 171 |
|
| 172 |
``` bnf
|
| 173 |
'R' *call-function* '(' conversion-type-id \ %
|
| 174 |
+
'F, P₁ a₁, …, Pₙ aₙ)' '{' return 'F (a₁, …, aₙ); }'
|
| 175 |
```
|
| 176 |
|
| 177 |
is also considered as a candidate function. Similarly, surrogate call
|
| 178 |
functions are added to the set of candidate functions for each
|
| 179 |
non-explicit conversion function declared in a base class of `T`
|