tmp/tmpau7_3ze4/{from.md → to.md}
RENAMED
|
@@ -14,12 +14,13 @@ class type, overload resolution is applied as specified in
|
|
| 14 |
|
| 15 |
If the *postfix-expression* denotes the address of a set of overloaded
|
| 16 |
functions and/or function templates, overload resolution is applied
|
| 17 |
using that set as described above. If the function selected by overload
|
| 18 |
resolution is a non-static member function, the program is ill-formed.
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
##### Call to named function <a id="over.call.func">[[over.call.func]]</a>
|
| 23 |
|
| 24 |
Of interest in [[over.call.func]] are only those function calls in
|
| 25 |
which the *postfix-expression* ultimately contains a name that denotes
|
|
@@ -42,12 +43,12 @@ In qualified function calls, the name to be resolved is an
|
|
| 42 |
construct `A->B` is generally equivalent to `(*A).B`, the rest of
|
| 43 |
Clause [[over]] assumes, without loss of generality, that all member
|
| 44 |
function calls have been normalized to the form that uses an object and
|
| 45 |
the `.` operator. Furthermore, Clause [[over]] assumes that the
|
| 46 |
*postfix-expression* that is the left operand of the `.` operator has
|
| 47 |
-
type “
|
| 48 |
-
|
| 49 |
following the rules for looking up names in classes (
|
| 50 |
[[class.member.lookup]]). The function declarations found by that lookup
|
| 51 |
constitute the set of candidate functions. The argument list is the
|
| 52 |
*expression-list* in the call augmented by the addition of the left
|
| 53 |
operand of the `.` operator in the normalized member function call as
|
|
@@ -73,32 +74,33 @@ and overload resolution selects one of the non-static member functions
|
|
| 73 |
of `T`, the call is ill-formed.
|
| 74 |
|
| 75 |
##### Call to object of class type <a id="over.call.object">[[over.call.object]]</a>
|
| 76 |
|
| 77 |
If the *primary-expression* `E` in the function call syntax evaluates to
|
| 78 |
-
a class object of type “
|
| 79 |
includes at least the function call operators of `T`. The function call
|
| 80 |
operators of `T` are obtained by ordinary lookup of the name
|
| 81 |
`operator()` in the context of `(E).operator()`.
|
| 82 |
|
| 83 |
In addition, for each non-explicit conversion function declared in `T`
|
| 84 |
of the form
|
| 85 |
|
| 86 |
``` bnf
|
| 87 |
-
'operator' conversion-type-id '( )' cv-qualifier ref-qualifierₒₚₜ
|
| 88 |
```
|
| 89 |
|
| 90 |
where *cv-qualifier* is the same cv-qualification as, or a greater
|
| 91 |
-
cv-qualification than,
|
| 92 |
-
type “pointer to function of (`
|
| 93 |
-
“reference to pointer to function of (`
|
| 94 |
-
the type “reference to function of (`
|
| 95 |
*surrogate call function* with the unique name *call-function* and
|
| 96 |
having the form
|
| 97 |
|
| 98 |
``` bnf
|
| 99 |
-
'R' call-function '(' conversion-type-id
|
|
|
|
| 100 |
```
|
| 101 |
|
| 102 |
is also considered as a candidate function. Similarly, surrogate call
|
| 103 |
functions are added to the set of candidate functions for each
|
| 104 |
non-explicit conversion function declared in a base class of `T`
|
|
@@ -112,28 +114,33 @@ then be invoked with the arguments of the call. If the conversion
|
|
| 112 |
function cannot be called (e.g., because of an ambiguity), the program
|
| 113 |
is ill-formed.
|
| 114 |
|
| 115 |
The argument list submitted to overload resolution consists of the
|
| 116 |
argument expressions present in the function call syntax preceded by the
|
| 117 |
-
implied object argument `(E)`.
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
``` cpp
|
| 128 |
int f1(int);
|
| 129 |
int f2(float);
|
| 130 |
typedef int (*fp1)(int);
|
| 131 |
typedef int (*fp2)(float);
|
| 132 |
struct A {
|
| 133 |
operator fp1() { return f1; }
|
| 134 |
operator fp2() { return f2; }
|
| 135 |
} a;
|
| 136 |
-
int i = a(1);
|
| 137 |
-
// conversion function
|
| 138 |
```
|
| 139 |
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
If the *postfix-expression* denotes the address of a set of overloaded
|
| 16 |
functions and/or function templates, overload resolution is applied
|
| 17 |
using that set as described above. If the function selected by overload
|
| 18 |
resolution is a non-static member function, the program is ill-formed.
|
| 19 |
+
|
| 20 |
+
[*Note 1*: The resolution of the address of an overload set in other
|
| 21 |
+
contexts is described in [[over.over]]. — *end note*]
|
| 22 |
|
| 23 |
##### Call to named function <a id="over.call.func">[[over.call.func]]</a>
|
| 24 |
|
| 25 |
Of interest in [[over.call.func]] are only those function calls in
|
| 26 |
which the *postfix-expression* ultimately contains a name that denotes
|
|
|
|
| 43 |
construct `A->B` is generally equivalent to `(*A).B`, the rest of
|
| 44 |
Clause [[over]] assumes, without loss of generality, that all member
|
| 45 |
function calls have been normalized to the form that uses an object and
|
| 46 |
the `.` operator. Furthermore, Clause [[over]] assumes that the
|
| 47 |
*postfix-expression* that is the left operand of the `.` operator has
|
| 48 |
+
type “cv `T`” where `T` denotes a class[^3]. Under this assumption, the
|
| 49 |
+
*id-expression* in the call is looked up as a member function of `T`
|
| 50 |
following the rules for looking up names in classes (
|
| 51 |
[[class.member.lookup]]). The function declarations found by that lookup
|
| 52 |
constitute the set of candidate functions. The argument list is the
|
| 53 |
*expression-list* in the call augmented by the addition of the left
|
| 54 |
operand of the `.` operator in the normalized member function call as
|
|
|
|
| 74 |
of `T`, the call is ill-formed.
|
| 75 |
|
| 76 |
##### Call to object of class type <a id="over.call.object">[[over.call.object]]</a>
|
| 77 |
|
| 78 |
If the *primary-expression* `E` in the function call syntax evaluates to
|
| 79 |
+
a class object of type “cv `T`”, then the set of candidate functions
|
| 80 |
includes at least the function call operators of `T`. The function call
|
| 81 |
operators of `T` are obtained by ordinary lookup of the name
|
| 82 |
`operator()` in the context of `(E).operator()`.
|
| 83 |
|
| 84 |
In addition, for each non-explicit conversion function declared in `T`
|
| 85 |
of the form
|
| 86 |
|
| 87 |
``` bnf
|
| 88 |
+
'operator' conversion-type-id '( )' cv-qualifier ref-qualifierₒₚₜ noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ ';'
|
| 89 |
```
|
| 90 |
|
| 91 |
where *cv-qualifier* is the same cv-qualification as, or a greater
|
| 92 |
+
cv-qualification than, cv, and where *conversion-type-id* denotes the
|
| 93 |
+
type “pointer to function of (`P₁`, …, `Pₙ`) returning `R`”, or the type
|
| 94 |
+
“reference to pointer to function of (`P₁`, …, `Pₙ`) returning `R`”, or
|
| 95 |
+
the type “reference to function of (`P₁`, …, `Pₙ`) returning `R`”, a
|
| 96 |
*surrogate call function* with the unique name *call-function* and
|
| 97 |
having the form
|
| 98 |
|
| 99 |
``` bnf
|
| 100 |
+
'R' call-function '(' conversion-type-id \ %
|
| 101 |
+
'F, P₁ a₁, …, Pₙ aₙ)' '{ return F (a₁, …, aₙ); }'
|
| 102 |
```
|
| 103 |
|
| 104 |
is also considered as a candidate function. Similarly, surrogate call
|
| 105 |
functions are added to the set of candidate functions for each
|
| 106 |
non-explicit conversion function declared in a base class of `T`
|
|
|
|
| 114 |
function cannot be called (e.g., because of an ambiguity), the program
|
| 115 |
is ill-formed.
|
| 116 |
|
| 117 |
The argument list submitted to overload resolution consists of the
|
| 118 |
argument expressions present in the function call syntax preceded by the
|
| 119 |
+
implied object argument `(E)`.
|
| 120 |
+
|
| 121 |
+
[*Note 2*: When comparing the call against the function call operators,
|
| 122 |
+
the implied object argument is compared against the implicit object
|
| 123 |
+
parameter of the function call operator. When comparing the call against
|
| 124 |
+
a surrogate call function, the implied object argument is compared
|
| 125 |
+
against the first parameter of the surrogate call function. The
|
| 126 |
+
conversion function from which the surrogate call function was derived
|
| 127 |
+
will be used in the conversion sequence for that parameter since it
|
| 128 |
+
converts the implied object argument to the appropriate function pointer
|
| 129 |
+
or reference required by that first parameter. — *end note*]
|
| 130 |
+
|
| 131 |
+
[*Example 1*:
|
| 132 |
|
| 133 |
``` cpp
|
| 134 |
int f1(int);
|
| 135 |
int f2(float);
|
| 136 |
typedef int (*fp1)(int);
|
| 137 |
typedef int (*fp2)(float);
|
| 138 |
struct A {
|
| 139 |
operator fp1() { return f1; }
|
| 140 |
operator fp2() { return f2; }
|
| 141 |
} a;
|
| 142 |
+
int i = a(1); // calls f1 via pointer returned from conversion function
|
|
|
|
| 143 |
```
|
| 144 |
|
| 145 |
+
— *end example*]
|
| 146 |
+
|