From Jason Turner

[over.ics.ref]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp4andocel/{from.md → to.md} +11 -11
tmp/tmp4andocel/{from.md → to.md} RENAMED
@@ -1,12 +1,12 @@
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
4
- an 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 {};
@@ -18,43 +18,43 @@ int i = f(b); // calls f(B&), an exact match, rather than f(A&), a convers
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]]), with the second
24
  standard conversion sequence 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
32
  copy-initializing a temporary of the referenced type with the argument
33
  expression. Any difference in top-level cv-qualification is subsumed by
34
  the initialization itself and does not constitute a conversion.
35
 
36
  Except for an implicit object parameter, for which see 
37
- [[over.match.funcs]], a standard conversion sequence cannot be formed if
38
- 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 7*: 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
46
  lvalue reference (see  [[dcl.init.ref]]). — *end note*]
47
 
48
  Other restrictions on binding a reference to a particular argument that
49
  are not based on the types of the reference and the argument do not
50
- affect the formation of a standard conversion sequence, however.
51
 
52
  [*Example 5*: A function with an “lvalue reference to `int`” parameter
53
  can be a viable candidate even if the corresponding argument is an `int`
54
  bit-field. The formation of implicit conversion sequences treats the
55
  `int` bit-field as an `int` lvalue and finds an exact match with the
56
  parameter. If the function is selected by overload resolution, the call
57
  will nonetheless be ill-formed because of the prohibition on binding a
58
- non-`const` lvalue reference to a bit-field (
59
- [[dcl.init.ref]]). — *end example*]
60
 
 
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 {};
 
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]], with the second
24
  standard conversion sequence 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
32
  copy-initializing a temporary of the referenced type with the argument
33
  expression. Any difference in top-level cv-qualification is subsumed by
34
  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 8*: 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
46
  lvalue reference (see  [[dcl.init.ref]]). — *end note*]
47
 
48
  Other restrictions on binding a reference to a particular argument that
49
  are not based on the types of the reference and the argument do not
50
+ affect the formation of an implicit conversion sequence, however.
51
 
52
  [*Example 5*: A function with an “lvalue reference to `int`” parameter
53
  can be a viable candidate even if the corresponding argument is an `int`
54
  bit-field. The formation of implicit conversion sequences treats the
55
  `int` bit-field as an `int` lvalue and finds an exact match with the
56
  parameter. If the function is selected by overload resolution, the call
57
  will nonetheless be ill-formed because of the prohibition on binding a
58
+ non-`const` lvalue reference to a bit-field
59
+ [[dcl.init.ref]]. — *end example*]
60