From Jason Turner

[over.call.func]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpz67lrl23/{from.md → to.md} +59 -33
tmp/tmpz67lrl23/{from.md → to.md} RENAMED
@@ -1,58 +1,75 @@
1
- ##### Call to named 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*
5
- that denotes one or more functions. Such a *postfix-expression*, perhaps
6
- nested arbitrarily deep in parentheses, has one of the following forms:
 
7
 
8
  ``` bnf
9
  postfix-expression:
10
  postfix-expression '.' id-expression
 
11
  postfix-expression '->' id-expression
12
- primary-expression
 
 
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 named by an *id-expression*
19
- preceded by an `->` or `.` operator. Since the construct `A->B` is
20
- generally equivalent to `(*A).B`, the rest of [[over]] assumes, without
21
- loss of generality, that all member function calls have been normalized
22
- to the form that uses an object and the `.` operator. Furthermore,
23
- [[over]] assumes that the *postfix-expression* that is the left operand
24
- of the `.` operator has type “cv `T`” where `T` denotes a class.[^2]
 
25
 
26
- The function declarations found by name lookup [[class.member.lookup]]
27
- constitute the set of candidate functions. The argument list is the
28
- *expression-list* in the call augmented by the addition of the left
29
- operand of the `.` operator in the normalized member function call as
30
- the implied object argument [[over.match.funcs]].
 
 
31
 
32
- In unqualified function calls, the function is named by a
33
- *primary-expression*. The function declarations found by name lookup
34
- [[basic.lookup]] constitute the set of candidate functions. Because of
35
- the rules for name lookup, the set of candidate functions consists
36
- either entirely of non-member functions or entirely of member functions
37
- of some class `T`. In the former case or if the *primary-expression* is
38
- the address of an overload set, the argument list is the same as the
39
- *expression-list* in the call. Otherwise, the argument list is the
40
- *expression-list* in the call augmented by the addition of an implied
41
- object argument as in a qualified function call. If the current class
42
- is, or is derived from, `T`, and the keyword `this` [[expr.prim.this]]
43
- refers to it, then the implied object argument is `(*this)`. Otherwise,
44
- a contrived object of type `T` becomes the implied object argument;[^3]
45
 
46
- if overload resolution selects a non-static member function, the call is
47
- ill-formed.
 
 
 
 
 
 
 
 
 
 
48
 
49
  [*Example 1*:
50
 
51
  ``` cpp
52
  struct C {
53
- void a();
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