From Jason Turner

[over.literal]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpm_xt1r9e/{from.md → to.md} +48 -51
tmp/tmpm_xt1r9e/{from.md → to.md} RENAMED
@@ -8,22 +8,23 @@ literal-operator-id:
8
 
9
  The *string-literal* or *user-defined-string-literal* in a
10
  *literal-operator-id* shall have no *encoding-prefix* and shall contain
11
  no characters other than the implicit terminating `'\0'`. The
12
  *ud-suffix* of the *user-defined-string-literal* or the *identifier* in
13
- a *literal-operator-id* is called a *literal suffix identifier*. Some
 
14
  literal suffix identifiers are reserved for future standardization; see 
15
  [[usrlit.suffix]]. A declaration whose *literal-operator-id* uses such a
16
  literal suffix identifier is ill-formed, no diagnostic required.
17
 
18
- A declaration whose *declarator-id* is a *literal-operator-id* shall be
19
- a declaration of a namespace-scope function or function template (it
20
- could be a friend function [[class.friend]]), an explicit instantiation
21
- or specialization of a function template, or a *using-declaration*
22
- [[namespace.udecl]]. A function declared with a *literal-operator-id* is
23
- a *literal operator*. A function template declared with a
24
- *literal-operator-id* is a *literal operator template*.
25
 
26
  The declaration of a literal operator shall have a
27
  *parameter-declaration-clause* equivalent to one of the following:
28
 
29
  ``` cpp
@@ -65,24 +66,26 @@ language linkage.
65
  invoked implicitly through user-defined literals [[lex.ext]]. However,
66
  except for the constraints described above, they are ordinary
67
  namespace-scope functions and function templates. In particular, they
68
  are looked up like ordinary functions and function templates and they
69
  follow the same overload resolution rules. Also, they can be declared
70
- `inline` or `constexpr`, they may have internal, module, or external
71
  linkage, they can be called explicitly, their addresses can be taken,
72
  etc. — *end note*]
73
 
74
  [*Example 1*:
75
 
76
  ``` cpp
77
  void operator ""_km(long double); // OK
78
- string operator "" _i18n(const char*, std::size_t); // OK
79
- template <char...> double operator "" _\u03C0(); // OK: UCN for lowercase pi
80
  float operator ""_e(const char*); // OK
81
- float operator ""E(const char*); // error: reserved literal suffix~([usrlit.suffix], [lex.ext])
82
- double operator""_Bq(long double); // OK: does not use the reserved identifier _Bq[lex.name]
83
- double operator"" _Bq(long double); // uses the reserved identifier _Bq[lex.name]
 
 
84
  float operator " "B(const char*); // error: non-empty string-literal
85
  string operator ""5X(const char*, std::size_t); // error: invalid literal suffix identifier
86
  double operator ""_miles(double); // error: invalid parameter-declaration-clause
87
  template <char...> int operator ""_j(const char*); // error: invalid parameter-declaration-clause
88
  extern "C" void operator ""_m(long double); // error: C language linkage
@@ -91,24 +94,24 @@ extern "C" void operator "" _m(long double); // error: C language linkage
91
  — *end example*]
92
 
93
  <!-- Link reference definitions -->
94
  [basic.lookup]: basic.md#basic.lookup
95
  [basic.lookup.argdep]: basic.md#basic.lookup.argdep
 
 
96
  [basic.stc.dynamic]: basic.md#basic.stc.dynamic
97
  [class.access]: class.md#class.access
98
  [class.conv]: class.md#class.conv
99
  [class.conv.ctor]: class.md#class.conv.ctor
100
  [class.conv.fct]: class.md#class.conv.fct
101
  [class.copy.assign]: class.md#class.copy.assign
102
  [class.copy.ctor]: class.md#class.copy.ctor
103
  [class.friend]: class.md#class.friend
104
  [class.inhctor.init]: class.md#class.inhctor.init
105
  [class.mem]: class.md#class.mem
106
- [class.member.lookup]: class.md#class.member.lookup
107
  [class.mfct]: class.md#class.mfct
108
- [class.static]: class.md#class.static
109
- [class.this]: class.md#class.this
110
  [conv]: expr.md#conv
111
  [conv.array]: expr.md#conv.array
112
  [conv.bool]: expr.md#conv.bool
113
  [conv.double]: expr.md#conv.double
114
  [conv.fctptr]: expr.md#conv.fctptr
@@ -119,14 +122,13 @@ extern "C" void operator "" _m(long double); // error: C language linkage
119
  [conv.lval]: expr.md#conv.lval
120
  [conv.mem]: expr.md#conv.mem
121
  [conv.prom]: expr.md#conv.prom
122
  [conv.ptr]: expr.md#conv.ptr
123
  [conv.qual]: expr.md#conv.qual
 
124
  [cpp.concat]: cpp.md#cpp.concat
125
  [cpp.stringize]: cpp.md#cpp.stringize
126
- [dcl.array]: dcl.md#dcl.array
127
- [dcl.decl]: dcl.md#dcl.decl
128
  [dcl.fct]: dcl.md#dcl.fct
129
  [dcl.fct.def.delete]: dcl.md#dcl.fct.def.delete
130
  [dcl.fct.default]: dcl.md#dcl.fct.default
131
  [dcl.fct.spec]: dcl.md#dcl.fct.spec
132
  [dcl.init]: dcl.md#dcl.init
@@ -134,12 +136,11 @@ extern "C" void operator "" _m(long double); // error: C language linkage
134
  [dcl.init.list]: dcl.md#dcl.init.list
135
  [dcl.init.ref]: dcl.md#dcl.init.ref
136
  [dcl.init.string]: dcl.md#dcl.init.string
137
  [dcl.type.class.deduct]: dcl.md#dcl.type.class.deduct
138
  [dcl.type.simple]: dcl.md#dcl.type.simple
139
- [dcl.typedef]: dcl.md#dcl.typedef
140
- [except.spec]: except.md#except.spec
141
  [expr.arith.conv]: expr.md#expr.arith.conv
142
  [expr.ass]: expr.md#expr.ass
143
  [expr.await]: expr.md#expr.await
144
  [expr.call]: expr.md#expr.call
145
  [expr.cast]: expr.md#expr.cast
@@ -147,10 +148,11 @@ extern "C" void operator "" _m(long double); // error: C language linkage
147
  [expr.cond]: expr.md#expr.cond
148
  [expr.eq]: expr.md#expr.eq
149
  [expr.mptr.oper]: expr.md#expr.mptr.oper
150
  [expr.pre.incr]: expr.md#expr.pre.incr
151
  [expr.prim.paren]: expr.md#expr.prim.paren
 
152
  [expr.rel]: expr.md#expr.rel
153
  [expr.spaceship]: expr.md#expr.spaceship
154
  [expr.static.cast]: expr.md#expr.static.cast
155
  [expr.sub]: expr.md#expr.sub
156
  [expr.type.conv]: expr.md#expr.type.conv
@@ -158,38 +160,43 @@ extern "C" void operator "" _m(long double); // error: C language linkage
158
  [lex.ext]: lex.md#lex.ext
159
  [namespace.udecl]: dcl.md#namespace.udecl
160
  [over]: #over
161
  [over.ass]: #over.ass
162
  [over.best.ics]: #over.best.ics
 
163
  [over.binary]: #over.binary
 
164
  [over.built]: #over.built
165
  [over.call]: #over.call
166
  [over.call.func]: #over.call.func
167
  [over.call.object]: #over.call.object
168
- [over.dcl]: #over.dcl
169
  [over.ics.ellipsis]: #over.ics.ellipsis
170
  [over.ics.list]: #over.ics.list
171
  [over.ics.rank]: #over.ics.rank
172
  [over.ics.ref]: #over.ics.ref
173
  [over.ics.scs]: #over.ics.scs
174
  [over.ics.user]: #over.ics.user
175
  [over.inc]: #over.inc
176
  [over.literal]: #over.literal
177
- [over.load]: #over.load
178
  [over.match]: #over.match
179
  [over.match.best]: #over.match.best
 
180
  [over.match.call]: #over.match.call
 
181
  [over.match.class.deduct]: #over.match.class.deduct
182
  [over.match.conv]: #over.match.conv
183
  [over.match.copy]: #over.match.copy
184
  [over.match.ctor]: #over.match.ctor
185
  [over.match.funcs]: #over.match.funcs
 
 
186
  [over.match.list]: #over.match.list
187
  [over.match.oper]: #over.match.oper
188
  [over.match.ref]: #over.match.ref
189
  [over.match.viable]: #over.match.viable
190
  [over.oper]: #over.oper
 
191
  [over.over]: #over.over
192
  [over.pre]: #over.pre
193
  [over.ref]: #over.ref
194
  [over.sub]: #over.sub
195
  [over.unary]: #over.unary
@@ -199,73 +206,63 @@ extern "C" void operator "" _m(long double); // error: C language linkage
199
  [temp.constr.constr]: temp.md#temp.constr.constr
200
  [temp.constr.decl]: temp.md#temp.constr.decl
201
  [temp.constr.order]: temp.md#temp.constr.order
202
  [temp.deduct]: temp.md#temp.deduct
203
  [temp.deduct.funcaddr]: temp.md#temp.deduct.funcaddr
 
204
  [temp.deduct.type]: temp.md#temp.deduct.type
205
  [temp.dep]: temp.md#temp.dep
206
  [temp.dep.type]: temp.md#temp.dep.type
207
  [temp.func.order]: temp.md#temp.func.order
208
  [temp.over]: temp.md#temp.over
209
- [temp.over.link]: temp.md#temp.over.link
210
  [temp.variadic]: temp.md#temp.variadic
211
  [usrlit.suffix]: library.md#usrlit.suffix
212
 
213
- [^1]: When a parameter type includes a function type, such as in the
214
- case of a parameter type that is a pointer to function, the `const`
215
- and `volatile` type-specifiers at the outermost level of the
216
- parameter type specifications for the inner function type are also
217
- ignored.
218
-
219
- [^2]: The process of argument deduction fully determines the parameter
220
  types of the function template specializations, i.e., the parameters
221
  of function template specializations contain no template parameter
222
  types. Therefore, except where specified otherwise, function
223
  template specializations and non-template functions [[dcl.fct]] are
224
  treated equivalently for the remainder of overload resolution.
225
 
226
- [^3]: Note that cv-qualifiers on the type of objects are significant in
227
  overload resolution for both glvalue and class prvalue objects.
228
 
229
- [^4]: An implied object argument must be contrived to correspond to the
230
  implicit object parameter attributed to member functions during
231
  overload resolution. It is not used in the call to the selected
232
  function. Since the member functions all have the same implicit
233
  object parameter, the contrived object will not be the cause to
234
  select or reject a function.
235
 
236
- [^5]: Note that this construction can yield candidate call functions
237
  that cannot be differentiated one from the other by overload
238
  resolution because they have identical declarations or differ only
239
  in their return type. The call will be ambiguous if overload
240
  resolution cannot select a match to the call that is uniquely better
241
  than such undifferentiable functions.
242
 
243
- [^6]: If the set of candidate functions is empty, overload resolution is
244
  unsuccessful.
245
 
246
- [^7]: If the value returned by the `operator->` function has class type,
247
- this may result in selecting and calling another `operator->`
248
  function. The process repeats until an `operator->` function returns
249
  a value of non-class type.
250
 
251
- [^8]: If a function is a static member function, this definition means
252
- that the first argument, the implied object argument, has no effect
253
- in the determination of whether the function is better or worse than
254
- any other function.
255
-
256
- [^9]: The algorithm for selecting the best viable function is linear in
257
  the number of viable functions. Run a simple tournament to find a
258
  function `W` that is not worse than any opponent it faced. Although
259
- another function `F` that `W` did not face might be at least as good
260
- as `W`, `F` cannot be the best function because at some point in the
261
- tournament `F` encountered another function `G` such that `F` was
262
- not better than `G`. Hence, either `W` is the best function or there
263
- is no best function. So, make a second pass over the viable
264
- functions to verify that `W` is better than all other functions.
 
265
 
266
- [^10]: Since there are no parameters of array type, this will only occur
267
  as the referenced type of a reference parameter.
268
 
269
- [^11]: Calling `operator++` explicitly, as in expressions like
270
  `a.operator++(2)`, has no special properties: The argument to
271
  `operator++` is `2`.
 
8
 
9
  The *string-literal* or *user-defined-string-literal* in a
10
  *literal-operator-id* shall have no *encoding-prefix* and shall contain
11
  no characters other than the implicit terminating `'\0'`. The
12
  *ud-suffix* of the *user-defined-string-literal* or the *identifier* in
13
+ a *literal-operator-id* is called a *literal suffix identifier*. The
14
+ first form of *literal-operator-id* is deprecated [[depr.lit]]. Some
15
  literal suffix identifiers are reserved for future standardization; see 
16
  [[usrlit.suffix]]. A declaration whose *literal-operator-id* uses such a
17
  literal suffix identifier is ill-formed, no diagnostic required.
18
 
19
+ A declaration whose *declarator-id* is a *literal-operator-id* shall
20
+ declare a function or function template that belongs to a namespace (it
21
+ could be a friend function [[class.friend]]) or an explicit
22
+ instantiation or specialization of a function template. A function
23
+ declared with a *literal-operator-id* is a *literal operator*. A
24
+ function template declared with a *literal-operator-id* is a *literal
25
+ operator template*.
26
 
27
  The declaration of a literal operator shall have a
28
  *parameter-declaration-clause* equivalent to one of the following:
29
 
30
  ``` cpp
 
66
  invoked implicitly through user-defined literals [[lex.ext]]. However,
67
  except for the constraints described above, they are ordinary
68
  namespace-scope functions and function templates. In particular, they
69
  are looked up like ordinary functions and function templates and they
70
  follow the same overload resolution rules. Also, they can be declared
71
+ `inline` or `constexpr`, they can have internal, module, or external
72
  linkage, they can be called explicitly, their addresses can be taken,
73
  etc. — *end note*]
74
 
75
  [*Example 1*:
76
 
77
  ``` cpp
78
  void operator ""_km(long double); // OK
79
+ string operator "" _i18n(const char*, std::size_t); // OK, deprecated
80
+ template <char...> double operator ""_\u03C0(); // OK, UCN for lowercase pi
81
  float operator ""_e(const char*); // OK
82
+ float operator ""E(const char*); // ill-formed, no diagnostic required:
83
+ // reserved literal suffix[usrlit.suffix,lex.ext]
84
+ double operator""_Bq(long double); // OK, does not use the reserved identifier _Bq[lex.name]
85
+ double operator"" _Bq(long double); // ill-formed, no diagnostic required:
86
+ // uses the reserved identifier _Bq[lex.name]
87
  float operator " "B(const char*); // error: non-empty string-literal
88
  string operator ""5X(const char*, std::size_t); // error: invalid literal suffix identifier
89
  double operator ""_miles(double); // error: invalid parameter-declaration-clause
90
  template <char...> int operator ""_j(const char*); // error: invalid parameter-declaration-clause
91
  extern "C" void operator ""_m(long double); // error: C language linkage
 
94
  — *end example*]
95
 
96
  <!-- Link reference definitions -->
97
  [basic.lookup]: basic.md#basic.lookup
98
  [basic.lookup.argdep]: basic.md#basic.lookup.argdep
99
+ [basic.lookup.unqual]: basic.md#basic.lookup.unqual
100
+ [basic.scope.scope]: basic.md#basic.scope.scope
101
  [basic.stc.dynamic]: basic.md#basic.stc.dynamic
102
  [class.access]: class.md#class.access
103
  [class.conv]: class.md#class.conv
104
  [class.conv.ctor]: class.md#class.conv.ctor
105
  [class.conv.fct]: class.md#class.conv.fct
106
  [class.copy.assign]: class.md#class.copy.assign
107
  [class.copy.ctor]: class.md#class.copy.ctor
108
  [class.friend]: class.md#class.friend
109
  [class.inhctor.init]: class.md#class.inhctor.init
110
  [class.mem]: class.md#class.mem
111
+ [class.member.lookup]: basic.md#class.member.lookup
112
  [class.mfct]: class.md#class.mfct
 
 
113
  [conv]: expr.md#conv
114
  [conv.array]: expr.md#conv.array
115
  [conv.bool]: expr.md#conv.bool
116
  [conv.double]: expr.md#conv.double
117
  [conv.fctptr]: expr.md#conv.fctptr
 
122
  [conv.lval]: expr.md#conv.lval
123
  [conv.mem]: expr.md#conv.mem
124
  [conv.prom]: expr.md#conv.prom
125
  [conv.ptr]: expr.md#conv.ptr
126
  [conv.qual]: expr.md#conv.qual
127
+ [conv.rank]: basic.md#conv.rank
128
  [cpp.concat]: cpp.md#cpp.concat
129
  [cpp.stringize]: cpp.md#cpp.stringize
 
 
130
  [dcl.fct]: dcl.md#dcl.fct
131
  [dcl.fct.def.delete]: dcl.md#dcl.fct.def.delete
132
  [dcl.fct.default]: dcl.md#dcl.fct.default
133
  [dcl.fct.spec]: dcl.md#dcl.fct.spec
134
  [dcl.init]: dcl.md#dcl.init
 
136
  [dcl.init.list]: dcl.md#dcl.init.list
137
  [dcl.init.ref]: dcl.md#dcl.init.ref
138
  [dcl.init.string]: dcl.md#dcl.init.string
139
  [dcl.type.class.deduct]: dcl.md#dcl.type.class.deduct
140
  [dcl.type.simple]: dcl.md#dcl.type.simple
141
+ [depr.lit]: future.md#depr.lit
 
142
  [expr.arith.conv]: expr.md#expr.arith.conv
143
  [expr.ass]: expr.md#expr.ass
144
  [expr.await]: expr.md#expr.await
145
  [expr.call]: expr.md#expr.call
146
  [expr.cast]: expr.md#expr.cast
 
148
  [expr.cond]: expr.md#expr.cond
149
  [expr.eq]: expr.md#expr.eq
150
  [expr.mptr.oper]: expr.md#expr.mptr.oper
151
  [expr.pre.incr]: expr.md#expr.pre.incr
152
  [expr.prim.paren]: expr.md#expr.prim.paren
153
+ [expr.prim.this]: expr.md#expr.prim.this
154
  [expr.rel]: expr.md#expr.rel
155
  [expr.spaceship]: expr.md#expr.spaceship
156
  [expr.static.cast]: expr.md#expr.static.cast
157
  [expr.sub]: expr.md#expr.sub
158
  [expr.type.conv]: expr.md#expr.type.conv
 
160
  [lex.ext]: lex.md#lex.ext
161
  [namespace.udecl]: dcl.md#namespace.udecl
162
  [over]: #over
163
  [over.ass]: #over.ass
164
  [over.best.ics]: #over.best.ics
165
+ [over.best.ics.general]: #over.best.ics.general
166
  [over.binary]: #over.binary
167
+ [over.binary.general]: #over.binary.general
168
  [over.built]: #over.built
169
  [over.call]: #over.call
170
  [over.call.func]: #over.call.func
171
  [over.call.object]: #over.call.object
 
172
  [over.ics.ellipsis]: #over.ics.ellipsis
173
  [over.ics.list]: #over.ics.list
174
  [over.ics.rank]: #over.ics.rank
175
  [over.ics.ref]: #over.ics.ref
176
  [over.ics.scs]: #over.ics.scs
177
  [over.ics.user]: #over.ics.user
178
  [over.inc]: #over.inc
179
  [over.literal]: #over.literal
 
180
  [over.match]: #over.match
181
  [over.match.best]: #over.match.best
182
+ [over.match.best.general]: #over.match.best.general
183
  [over.match.call]: #over.match.call
184
+ [over.match.call.general]: #over.match.call.general
185
  [over.match.class.deduct]: #over.match.class.deduct
186
  [over.match.conv]: #over.match.conv
187
  [over.match.copy]: #over.match.copy
188
  [over.match.ctor]: #over.match.ctor
189
  [over.match.funcs]: #over.match.funcs
190
+ [over.match.funcs.general]: #over.match.funcs.general
191
+ [over.match.general]: #over.match.general
192
  [over.match.list]: #over.match.list
193
  [over.match.oper]: #over.match.oper
194
  [over.match.ref]: #over.match.ref
195
  [over.match.viable]: #over.match.viable
196
  [over.oper]: #over.oper
197
+ [over.oper.general]: #over.oper.general
198
  [over.over]: #over.over
199
  [over.pre]: #over.pre
200
  [over.ref]: #over.ref
201
  [over.sub]: #over.sub
202
  [over.unary]: #over.unary
 
206
  [temp.constr.constr]: temp.md#temp.constr.constr
207
  [temp.constr.decl]: temp.md#temp.constr.decl
208
  [temp.constr.order]: temp.md#temp.constr.order
209
  [temp.deduct]: temp.md#temp.deduct
210
  [temp.deduct.funcaddr]: temp.md#temp.deduct.funcaddr
211
+ [temp.deduct.guide]: temp.md#temp.deduct.guide
212
  [temp.deduct.type]: temp.md#temp.deduct.type
213
  [temp.dep]: temp.md#temp.dep
214
  [temp.dep.type]: temp.md#temp.dep.type
215
  [temp.func.order]: temp.md#temp.func.order
216
  [temp.over]: temp.md#temp.over
 
217
  [temp.variadic]: temp.md#temp.variadic
218
  [usrlit.suffix]: library.md#usrlit.suffix
219
 
220
+ [^1]: The process of argument deduction fully determines the parameter
 
 
 
 
 
 
221
  types of the function template specializations, i.e., the parameters
222
  of function template specializations contain no template parameter
223
  types. Therefore, except where specified otherwise, function
224
  template specializations and non-template functions [[dcl.fct]] are
225
  treated equivalently for the remainder of overload resolution.
226
 
227
+ [^2]: Note that cv-qualifiers on the type of objects are significant in
228
  overload resolution for both glvalue and class prvalue objects.
229
 
230
+ [^3]: An implied object argument is contrived to correspond to the
231
  implicit object parameter attributed to member functions during
232
  overload resolution. It is not used in the call to the selected
233
  function. Since the member functions all have the same implicit
234
  object parameter, the contrived object will not be the cause to
235
  select or reject a function.
236
 
237
+ [^4]: Note that this construction can yield candidate call functions
238
  that cannot be differentiated one from the other by overload
239
  resolution because they have identical declarations or differ only
240
  in their return type. The call will be ambiguous if overload
241
  resolution cannot select a match to the call that is uniquely better
242
  than such undifferentiable functions.
243
 
244
+ [^5]: If the set of candidate functions is empty, overload resolution is
245
  unsuccessful.
246
 
247
+ [^6]: If the value returned by the `operator->` function has class type,
248
+ this can result in selecting and calling another `operator->`
249
  function. The process repeats until an `operator->` function returns
250
  a value of non-class type.
251
 
252
+ [^7]: The algorithm for selecting the best viable function is linear in
 
 
 
 
 
253
  the number of viable functions. Run a simple tournament to find a
254
  function `W` that is not worse than any opponent it faced. Although
255
+ it is possible that another function `F` that `W` did not face is at
256
+ least as good as `W`, `F` cannot be the best function because at
257
+ some point in the tournament `F` encountered another function `G`
258
+ such that `F` was not better than `G`. Hence, either `W` is the best
259
+ function or there is no best function. So, make a second pass over
260
+ the viable functions to verify that `W` is better than all other
261
+ functions.
262
 
263
+ [^8]: Since there are no parameters of array type, this will only occur
264
  as the referenced type of a reference parameter.
265
 
266
+ [^9]: Calling `operator++` explicitly, as in expressions like
267
  `a.operator++(2)`, has no special properties: The argument to
268
  `operator++` is `2`.