From Jason Turner

[over.call.object]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpqeyl502d/{from.md → to.md} +24 -18
tmp/tmpqeyl502d/{from.md → to.md} RENAMED
@@ -1,30 +1,31 @@
1
  ##### Call to object of class type <a id="over.call.object">[[over.call.object]]</a>
2
 
3
  If the *primary-expression* `E` in the function call syntax evaluates to
4
- a class object of type “*cv* `T`”, then the set of candidate functions
5
  includes at least the function call operators of `T`. The function call
6
  operators of `T` are obtained by ordinary lookup of the name
7
  `operator()` in the context of `(E).operator()`.
8
 
9
  In addition, for each non-explicit conversion function declared in `T`
10
  of the form
11
 
12
  ``` bnf
13
- 'operator' conversion-type-id '( )' cv-qualifier ref-qualifierₒₚₜ exception-specificationₒₚₜ attribute-specifier-seqₒₚₜ ';'
14
  ```
15
 
16
  where *cv-qualifier* is the same cv-qualification as, or a greater
17
- cv-qualification than, *cv*, and where *conversion-type-id* denotes the
18
- type “pointer to function of (`P1`,...,`Pn)` returning `R`”, or the type
19
- “reference to pointer to function of (`P1`,...,`Pn)` returning `R`”, or
20
- the type “reference to function of (`P1`,...,`Pn)` returning `R`”, a
21
  *surrogate call function* with the unique name *call-function* and
22
  having the form
23
 
24
  ``` bnf
25
- 'R' call-function '(' conversion-type-id 'F, P1 a1, ... ,Pn an)' '{ return F (a1,... ,an); }'
 
26
  ```
27
 
28
  is also considered as a candidate function. Similarly, surrogate call
29
  functions are added to the set of candidate functions for each
30
  non-explicit conversion function declared in a base class of `T`
@@ -38,28 +39,33 @@ then be invoked with the arguments of the call. If the conversion
38
  function cannot be called (e.g., because of an ambiguity), the program
39
  is ill-formed.
40
 
41
  The argument list submitted to overload resolution consists of the
42
  argument expressions present in the function call syntax preceded by the
43
- implied object argument `(E)`. When comparing the call against the
44
- function call operators, the implied object argument is compared against
45
- the implicit object parameter of the function call operator. When
46
- comparing the call against a surrogate call function, the implied object
47
- argument is compared against the first parameter of the surrogate call
48
- function. The conversion function from which the surrogate call function
49
- was derived will be used in the conversion sequence for that parameter
50
- since it converts the implied object argument to the appropriate
51
- function pointer or reference required by that first parameter.
 
 
 
 
52
 
53
  ``` cpp
54
  int f1(int);
55
  int f2(float);
56
  typedef int (*fp1)(int);
57
  typedef int (*fp2)(float);
58
  struct A {
59
  operator fp1() { return f1; }
60
  operator fp2() { return f2; }
61
  } a;
62
- int i = a(1); // calls f1 via pointer returned from
63
- // conversion function
64
  ```
65
 
 
 
 
1
  ##### Call to object of class type <a id="over.call.object">[[over.call.object]]</a>
2
 
3
  If the *primary-expression* `E` in the function call syntax evaluates to
4
+ a class object of type “cv `T`”, then the set of candidate functions
5
  includes at least the function call operators of `T`. The function call
6
  operators of `T` are obtained by ordinary lookup of the name
7
  `operator()` in the context of `(E).operator()`.
8
 
9
  In addition, for each non-explicit conversion function declared in `T`
10
  of the form
11
 
12
  ``` bnf
13
+ 'operator' conversion-type-id '( )' cv-qualifier ref-qualifierₒₚₜ noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ ';'
14
  ```
15
 
16
  where *cv-qualifier* is the same cv-qualification as, or a greater
17
+ cv-qualification than, cv, and where *conversion-type-id* denotes the
18
+ type “pointer to function of (`P₁`,, `Pₙ`) returning `R`”, or the type
19
+ “reference to pointer to function of (`P₁`,, `Pₙ`) returning `R`”, or
20
+ the type “reference to function of (`P₁`,, `Pₙ`) returning `R`”, a
21
  *surrogate call function* with the unique name *call-function* and
22
  having the form
23
 
24
  ``` bnf
25
+ 'R' call-function '(' conversion-type-id \ %
26
+ 'F, P₁ a₁, …, Pₙ aₙ)' '{ return F (a₁, …, aₙ); }'
27
  ```
28
 
29
  is also considered as a candidate function. Similarly, surrogate call
30
  functions are added to the set of candidate functions for each
31
  non-explicit conversion function declared in a base class of `T`
 
39
  function cannot be called (e.g., because of an ambiguity), the program
40
  is ill-formed.
41
 
42
  The argument list submitted to overload resolution consists of the
43
  argument expressions present in the function call syntax preceded by the
44
+ implied object argument `(E)`.
45
+
46
+ [*Note 2*: When comparing the call against the function call operators,
47
+ the implied object argument is compared against the implicit object
48
+ parameter of the function call operator. When comparing the call against
49
+ a surrogate call function, the implied object argument is compared
50
+ against the first parameter of the surrogate call function. The
51
+ conversion function from which the surrogate call function was derived
52
+ will be used in the conversion sequence for that parameter since it
53
+ converts the implied object argument to the appropriate function pointer
54
+ or reference required by that first parameter. — *end note*]
55
+
56
+ [*Example 1*:
57
 
58
  ``` cpp
59
  int f1(int);
60
  int f2(float);
61
  typedef int (*fp1)(int);
62
  typedef int (*fp2)(float);
63
  struct A {
64
  operator fp1() { return f1; }
65
  operator fp2() { return f2; }
66
  } a;
67
+ int i = a(1); // calls f1 via pointer returned from conversion function
 
68
  ```
69
 
70
+ — *end example*]
71
+