tmp/tmpz67lrl23/{from.md → to.md}
RENAMED
|
@@ -1,58 +1,75 @@
|
|
| 1 |
-
##### Call to
|
| 2 |
|
| 3 |
Of interest in [[over.call.func]] are only those function calls in
|
| 4 |
-
which the *postfix-expression* ultimately contains an *id-expression*
|
| 5 |
-
that
|
| 6 |
-
nested arbitrarily deep in parentheses,
|
|
|
|
| 7 |
|
| 8 |
``` bnf
|
| 9 |
postfix-expression:
|
| 10 |
postfix-expression '.' id-expression
|
|
|
|
| 11 |
postfix-expression '->' id-expression
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
```
|
| 14 |
|
| 15 |
These represent two syntactic subcategories of function calls: qualified
|
| 16 |
function calls and unqualified function calls.
|
| 17 |
|
| 18 |
-
In qualified function calls, the function is
|
| 19 |
-
preceded by an `->` or `.`
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
[[over]] assumes that the
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
-
The
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
the
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
In unqualified function calls, the function is
|
| 33 |
-
*
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
*
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
|
| 46 |
-
if
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
[*Example 1*:
|
| 50 |
|
| 51 |
``` cpp
|
| 52 |
struct C {
|
| 53 |
-
|
| 54 |
void b() {
|
| 55 |
a(); // OK, (*this).a()
|
| 56 |
}
|
| 57 |
|
| 58 |
void c(this const C&); // #1
|
|
@@ -85,10 +102,19 @@ void d() {
|
|
| 85 |
void k(this int);
|
| 86 |
operator int() const;
|
| 87 |
void m(this const C& c) {
|
| 88 |
c.k(); // OK
|
| 89 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
};
|
| 91 |
```
|
| 92 |
|
| 93 |
— *end example*]
|
| 94 |
|
|
|
|
| 1 |
+
##### Call to designated function <a id="over.call.func">[[over.call.func]]</a>
|
| 2 |
|
| 3 |
Of interest in [[over.call.func]] are only those function calls in
|
| 4 |
+
which the *postfix-expression* ultimately contains an *id-expression* or
|
| 5 |
+
*splice-expression* that designates one or more functions. Such a
|
| 6 |
+
*postfix-expression*, perhaps nested arbitrarily deep in parentheses,
|
| 7 |
+
has one of the following forms:
|
| 8 |
|
| 9 |
``` bnf
|
| 10 |
postfix-expression:
|
| 11 |
postfix-expression '.' id-expression
|
| 12 |
+
postfix-expression '.' splice-expression
|
| 13 |
postfix-expression '->' id-expression
|
| 14 |
+
postfix-expression '->' splice-expression
|
| 15 |
+
id-expression
|
| 16 |
+
splice-expression
|
| 17 |
```
|
| 18 |
|
| 19 |
These represent two syntactic subcategories of function calls: qualified
|
| 20 |
function calls and unqualified function calls.
|
| 21 |
|
| 22 |
+
In qualified function calls, the function is designated by an
|
| 23 |
+
*id-expression* or *splice-expression* E preceded by an `->` or `.`
|
| 24 |
+
operator. Since the construct `A->B` is generally equivalent to
|
| 25 |
+
`(*A).B`, the rest of [[over]] assumes, without loss of generality, that
|
| 26 |
+
all member function calls have been normalized to the form that uses an
|
| 27 |
+
object and the `.` operator. Furthermore, [[over]] assumes that the
|
| 28 |
+
*postfix-expression* that is the left operand of the `.` operator has
|
| 29 |
+
type “cv `T`” where `T` denotes a class.[^2]
|
| 30 |
|
| 31 |
+
The set of candidate functions either is the set found by name lookup
|
| 32 |
+
[[class.member.lookup]] if E is an *id-expression* or is the set
|
| 33 |
+
determined as specified in [[expr.prim.splice]] if E is a
|
| 34 |
+
*splice-expression*. The argument list is the *expression-list* in the
|
| 35 |
+
call augmented by the addition of the left operand of the `.` operator
|
| 36 |
+
in the normalized member function call as the implied object argument
|
| 37 |
+
[[over.match.funcs]].
|
| 38 |
|
| 39 |
+
In unqualified function calls, the function is designated by an
|
| 40 |
+
*id-expression* or a *splice-expression* E. The set of candidate
|
| 41 |
+
functions either is the set found by name lookup [[basic.lookup]] if E
|
| 42 |
+
is an *id-expression* or is the set determined as specified in
|
| 43 |
+
[[expr.prim.splice]] if E is a *splice-expression*. The set of candidate
|
| 44 |
+
functions consists either entirely of non-member functions or entirely
|
| 45 |
+
of member functions of some class `T`. In the former case or if E is
|
| 46 |
+
either a *splice-expression* or the address of an overload set, the
|
| 47 |
+
argument list is the same as the *expression-list* in the call.
|
| 48 |
+
Otherwise, the argument list is the *expression-list* in the call
|
| 49 |
+
augmented by the addition of an implied object argument as in a
|
| 50 |
+
qualified function call. If the current class is, or is derived from,
|
| 51 |
+
`T`, and the keyword `this` [[expr.prim.this]] refers to it,
|
| 52 |
|
| 53 |
+
- if the unqualified function call appears in a precondition assertion
|
| 54 |
+
of a constructor or a postcondition assertion of a destructor and
|
| 55 |
+
overload resolution selects a non-static member function, the call is
|
| 56 |
+
ill-formed;
|
| 57 |
+
- otherwise, the implied object argument is `(*this)`.
|
| 58 |
+
|
| 59 |
+
Otherwise,
|
| 60 |
+
|
| 61 |
+
- if overload resolution selects a non-static member function, the call
|
| 62 |
+
is ill-formed;
|
| 63 |
+
- otherwise, a contrived object of type `T` becomes the implied object
|
| 64 |
+
argument.[^3]
|
| 65 |
|
| 66 |
[*Example 1*:
|
| 67 |
|
| 68 |
``` cpp
|
| 69 |
struct C {
|
| 70 |
+
bool a();
|
| 71 |
void b() {
|
| 72 |
a(); // OK, (*this).a()
|
| 73 |
}
|
| 74 |
|
| 75 |
void c(this const C&); // #1
|
|
|
|
| 102 |
void k(this int);
|
| 103 |
operator int() const;
|
| 104 |
void m(this const C& c) {
|
| 105 |
c.k(); // OK
|
| 106 |
}
|
| 107 |
+
|
| 108 |
+
C()
|
| 109 |
+
pre(a()) // error: implied this in constructor precondition
|
| 110 |
+
pre(this->a()) // OK
|
| 111 |
+
post(a()); // OK
|
| 112 |
+
~C()
|
| 113 |
+
pre(a()) // OK
|
| 114 |
+
post(a()) // error: implied this in destructor postcondition
|
| 115 |
+
post(this->a()); // OK
|
| 116 |
};
|
| 117 |
```
|
| 118 |
|
| 119 |
— *end example*]
|
| 120 |
|