From Jason Turner

[over.ics.ref]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpcbi8jb19/{from.md → to.md} +22 -9
tmp/tmpcbi8jb19/{from.md → to.md} RENAMED
@@ -1,31 +1,44 @@
1
  ##### Reference binding <a id="over.ics.ref">[[over.ics.ref]]</a>
2
 
3
- When a parameter of reference type binds directly [[dcl.init.ref]] to an
4
- argument expression, the implicit conversion sequence is the identity
5
- conversion, unless the argument expression has a type that is a derived
6
- class of the parameter type, in which case the implicit conversion
7
- sequence is a derived-to-base conversion [[over.best.ics]].
 
 
 
 
 
 
 
 
 
 
8
 
9
  [*Example 4*:
10
 
11
  ``` cpp
12
  struct A {};
13
  struct B : public A {} b;
14
  int f(A&);
15
  int f(B&);
16
  int i = f(b); // calls f(B&), an exact match, rather than f(A&), a conversion
 
 
 
 
 
17
  ```
18
 
19
  — *end example*]
20
 
21
  If the parameter binds directly to the result of applying a conversion
22
  function to the argument expression, the implicit conversion sequence is
23
  a user-defined conversion sequence [[over.ics.user]] whose second
24
- standard conversion sequence is either an identity conversion or, if the
25
- conversion function returns an entity of a type that is a derived class
26
- of the parameter type, a derived-to-base conversion.
27
 
28
  When a parameter of reference type is not bound directly to an argument
29
  expression, the conversion sequence is the one required to convert the
30
  argument expression to the referenced type according to 
31
  [[over.best.ics]]. Conceptually, this conversion sequence corresponds to
@@ -35,11 +48,11 @@ the initialization itself and does not constitute a conversion.
35
 
36
  Except for an implicit object parameter, for which see 
37
  [[over.match.funcs]], an implicit conversion sequence cannot be formed
38
  if it requires binding an lvalue reference other than a reference to a
39
  non-volatile `const` type to an rvalue or binding an rvalue reference to
40
- an lvalue other than a function lvalue.
41
 
42
  [*Note 9*: This means, for example, that a candidate function cannot be
43
  a viable function if it has a non-`const` lvalue reference parameter
44
  (other than the implicit object parameter) and the corresponding
45
  argument would require a temporary to be created to initialize the
 
1
  ##### Reference binding <a id="over.ics.ref">[[over.ics.ref]]</a>
2
 
3
+ When a parameter of type “reference to cv `T`” binds directly
4
+ [[dcl.init.ref]] to an argument expression:
5
+
6
+ - If the argument expression has a type that is a derived class of the
7
+ parameter type, the implicit conversion sequence is a derived-to-base
8
+ conversion [[over.best.ics]].
9
+ - Otherwise, if the type of the argument is possibly cv-qualified `T`,
10
+ or if `T` is an array type of unknown bound with element type `U` and
11
+ the argument has an array type of known bound whose element type is
12
+ possibly cv-qualified `U`, the implicit conversion sequence is the
13
+ identity conversion.
14
+ - Otherwise, if `T` is a function type, the implicit conversion sequence
15
+ is a function pointer conversion.
16
+ - Otherwise, the implicit conversion sequence is a qualification
17
+ conversion.
18
 
19
  [*Example 4*:
20
 
21
  ``` cpp
22
  struct A {};
23
  struct B : public A {} b;
24
  int f(A&);
25
  int f(B&);
26
  int i = f(b); // calls f(B&), an exact match, rather than f(A&), a conversion
27
+
28
+ void g() noexcept;
29
+ int h(void (&)() noexcept); // #1
30
+ int h(void (&)()); // #2
31
+ int j = h(g); // calls #1, an exact match, rather than #2, a function pointer conversion
32
  ```
33
 
34
  — *end example*]
35
 
36
  If the parameter binds directly to the result of applying a conversion
37
  function to the argument expression, the implicit conversion sequence is
38
  a user-defined conversion sequence [[over.ics.user]] whose second
39
+ standard conversion sequence is determined by the above rules.
 
 
40
 
41
  When a parameter of reference type is not bound directly to an argument
42
  expression, the conversion sequence is the one required to convert the
43
  argument expression to the referenced type according to 
44
  [[over.best.ics]]. Conceptually, this conversion sequence corresponds to
 
48
 
49
  Except for an implicit object parameter, for which see 
50
  [[over.match.funcs]], an implicit conversion sequence cannot be formed
51
  if it requires binding an lvalue reference other than a reference to a
52
  non-volatile `const` type to an rvalue or binding an rvalue reference to
53
+ an lvalue of object type.
54
 
55
  [*Note 9*: This means, for example, that a candidate function cannot be
56
  a viable function if it has a non-`const` lvalue reference parameter
57
  (other than the implicit object parameter) and the corresponding
58
  argument would require a temporary to be created to initialize the