From Jason Turner

[class.conv.fct]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpk7phf7gq/{from.md → to.md} +17 -18
tmp/tmpk7phf7gq/{from.md → to.md} RENAMED
@@ -18,39 +18,38 @@ conversion-declarator:
18
  A declaration whose *declarator-id* has an *unqualified-id* that is a
19
  *conversion-function-id* declares a *conversion function*; its
20
  *declarator* shall be a function declarator [[dcl.fct]] of the form
21
 
22
  ``` bnf
23
- ptr-declarator '(' parameter-declaration-clause ')' cv-qualifier-seqₒₚₜ
24
- ref-qualifier-seqₒₚₜ noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ
25
  ```
26
 
27
- where the *ptr-declarator* consists solely of an *id-expression*, an
28
  optional *attribute-specifier-seq*, and optional surrounding
29
  parentheses, and the *id-expression* has one of the following forms:
30
 
31
  - in a *member-declaration* that belongs to the *member-specification*
32
  of a class or class template but is not a friend declaration
33
  [[class.friend]], the *id-expression* is a *conversion-function-id*;
34
  - otherwise, the *id-expression* is a *qualified-id* whose
35
  *unqualified-id* is a *conversion-function-id*.
36
 
37
  A conversion function shall have no non-object parameters and shall be a
38
- non-static member function of a class or class template `X`; it
39
- specifies a conversion from `X` to the type specified by the
40
- *conversion-type-id*, interpreted as a *type-id* [[dcl.name]]. A
41
- *decl-specifier* in the *decl-specifier-seq* of a conversion function
42
- (if any) shall not be a *defining-type-specifier*.
 
43
 
44
- The type of the conversion function is “`noexcept`ₒₚₜ function taking
45
- no parameter *cv-qualifier-seq*ₒₚₜ *ref-qualifier*ₒₚₜ returning
46
- *conversion-type-id*”.
47
-
48
- A conversion function is never used to convert a (possibly cv-qualified)
49
- object to the (possibly cv-qualified) same object type (or a reference
50
- to it), to a (possibly cv-qualified) base class of that type (or a
51
- reference to it), or to cv `void`.[^6]
52
 
53
  [*Example 1*:
54
 
55
  ``` cpp
56
  struct X {
@@ -102,11 +101,11 @@ void g(X a, X b) {
102
  The *conversion-type-id* shall not represent a function type nor an
103
  array type. The *conversion-type-id* in a *conversion-function-id* is
104
  the longest sequence of tokens that could possibly form a
105
  *conversion-type-id*.
106
 
107
- [*Note 1*:
108
 
109
  This prevents ambiguities between the declarator operator `*` and its
110
  expression counterparts.
111
 
112
  [*Example 3*:
@@ -131,11 +130,11 @@ operator int [[noreturn]] (); // error: noreturn attribute applied to a type
131
 
132
  — *end example*]
133
 
134
  — *end note*]
135
 
136
- [*Note 2*:
137
 
138
  A conversion function in a derived class hides only conversion functions
139
  in base classes that convert to the same type. A conversion function
140
  template with a dependent return type hides only templates in base
141
  classes that correspond to it [[class.member.lookup]]; otherwise, it
 
18
  A declaration whose *declarator-id* has an *unqualified-id* that is a
19
  *conversion-function-id* declares a *conversion function*; its
20
  *declarator* shall be a function declarator [[dcl.fct]] of the form
21
 
22
  ``` bnf
23
+ noptr-declarator parameters-and-qualifiers
 
24
  ```
25
 
26
+ where the *noptr-declarator* consists solely of an *id-expression*, an
27
  optional *attribute-specifier-seq*, and optional surrounding
28
  parentheses, and the *id-expression* has one of the following forms:
29
 
30
  - in a *member-declaration* that belongs to the *member-specification*
31
  of a class or class template but is not a friend declaration
32
  [[class.friend]], the *id-expression* is a *conversion-function-id*;
33
  - otherwise, the *id-expression* is a *qualified-id* whose
34
  *unqualified-id* is a *conversion-function-id*.
35
 
36
  A conversion function shall have no non-object parameters and shall be a
37
+ non-static member function of a class or class template `X`; its
38
+ declared return type is the *conversion-type-id* and it specifies a
39
+ conversion from `X` to the type specified by the *conversion-type-id*,
40
+ interpreted as a *type-id* [[dcl.name]]. A *decl-specifier* in the
41
+ *decl-specifier-seq* of a conversion function (if any) shall not be a
42
+ *defining-type-specifier*.
43
 
44
+ [*Note 1*: A conversion function is never invoked for implicit or
45
+ explicit conversions of an object to the same object type (or a
46
+ reference to it), to a base class of that type (or a reference to it),
47
+ or to cv `void`. Even though never directly called to perform a
48
+ conversion, such conversion functions can be declared and can
49
+ potentially be reached through a call to a virtual conversion function
50
+ in a base class. *end note*]
 
51
 
52
  [*Example 1*:
53
 
54
  ``` cpp
55
  struct X {
 
101
  The *conversion-type-id* shall not represent a function type nor an
102
  array type. The *conversion-type-id* in a *conversion-function-id* is
103
  the longest sequence of tokens that could possibly form a
104
  *conversion-type-id*.
105
 
106
+ [*Note 2*:
107
 
108
  This prevents ambiguities between the declarator operator `*` and its
109
  expression counterparts.
110
 
111
  [*Example 3*:
 
130
 
131
  — *end example*]
132
 
133
  — *end note*]
134
 
135
+ [*Note 3*:
136
 
137
  A conversion function in a derived class hides only conversion functions
138
  in base classes that convert to the same type. A conversion function
139
  template with a dependent return type hides only templates in base
140
  classes that correspond to it [[class.member.lookup]]; otherwise, it