From Jason Turner

[over.built]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp7ajmr6ij/{from.md → to.md} +51 -194
tmp/tmp7ajmr6ij/{from.md → to.md} RENAMED
@@ -1,9 +1,9 @@
1
  ## Built-in operators <a id="over.built">[[over.built]]</a>
2
 
3
  The candidate operator functions that represent the built-in operators
4
- defined in Clause  [[expr]] are specified in this subclause. These
5
  candidate functions participate in the operator overload resolution
6
  process as described in  [[over.match.oper]] and are used for no other
7
  purpose.
8
 
9
  [*Note 1*: Because built-in operators take only operands with non-class
@@ -15,27 +15,26 @@ appropriate for the operator, or when an operand has an enumeration type
15
  that can be converted to a type appropriate for the operator. Also note
16
  that some of the candidate operator functions given in this subclause
17
  are more permissive than the built-in operators themselves. As described
18
  in  [[over.match.oper]], after a built-in operator is selected by
19
  overload resolution the expression is subject to the requirements for
20
- the built-in operator given in Clause  [[expr]], and therefore to any
21
  additional semantic constraints given there. If there is a user-written
22
  candidate with the same name and parameter types as a built-in candidate
23
  operator function, the built-in operator function is hidden and is not
24
  included in the set of candidate functions. — *end note*]
25
 
26
  In this subclause, the term *promoted integral type* is used to refer to
27
- those integral types which are preserved by integral promotion (
28
- [[conv.prom]]) (including e.g. `int` and `long` but excluding e.g.
29
- `char`). Similarly, the term *promoted arithmetic type* refers to
30
- floating types plus promoted integral types.
31
 
32
- [*Note 2*: In all cases where a promoted integral type or promoted
33
- arithmetic type is required, an operand of enumeration type will be
34
- acceptable by way of the integral promotions. — *end note*]
35
 
36
- In the remainder of this section, *vq* represents either `volatile` or
37
  no cv-qualifier.
38
 
39
  For every pair (`T`, *vq*), where `T` is an arithmetic type other than
40
  `bool`, there exist candidate operator functions of the form
41
 
@@ -81,12 +80,12 @@ For every type `T` there exist candidate operator functions of the form
81
 
82
  ``` cpp
83
  T* operator+(T*);
84
  ```
85
 
86
- For every promoted arithmetic type `T`, there exist candidate operator
87
- functions of the form
88
 
89
  ``` cpp
90
  T operator+(T);
91
  T operator-(T);
92
  ```
@@ -109,28 +108,43 @@ cv12 T& operator->*(cv1 C1*, cv2 T C2::*);
109
 
110
  where *cv12* is the union of *cv1* and *cv2*. The return type is shown
111
  for exposition only; see  [[expr.mptr.oper]] for the determination of
112
  the operator’s result type.
113
 
114
- For every pair of promoted arithmetic types `L` and `R`, there exist
115
- candidate operator functions of the form
 
116
 
117
  ``` cpp
118
  LR operator*(L, R);
119
  LR operator/(L, R);
120
  LR operator+(L, R);
121
  LR operator-(L, R);
 
 
122
  bool operator<(L, R);
123
  bool operator>(L, R);
124
  bool operator<=(L, R);
125
  bool operator>=(L, R);
126
- bool operator==(L, R);
127
- bool operator!=(L, R);
128
  ```
129
 
130
- where `LR` is the result of the usual arithmetic conversions between
131
- types `L` and `R`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
  For every cv-qualified or cv-unqualified object type `T` there exist
134
  candidate operator functions of the form
135
 
136
  ``` cpp
@@ -150,20 +164,23 @@ std::ptrdiff_t operator-(T, T);
150
 
151
  For every `T`, where `T` is an enumeration type or a pointer type, there
152
  exist candidate operator functions of the form
153
 
154
  ``` cpp
 
 
155
  bool operator<(T, T);
156
  bool operator>(T, T);
157
  bool operator<=(T, T);
158
  bool operator>=(T, T);
159
- bool operator==(T, T);
160
- bool operator!=(T, T);
161
  ```
162
 
163
- For every pointer to member type `T` or type `std::nullptr_t` there
164
- exist candidate operator functions of the form
 
 
165
 
166
  ``` cpp
167
  bool operator==(T, T);
168
  bool operator!=(T, T);
169
  ```
@@ -178,16 +195,16 @@ LR operator^(L, R);
178
  LR operator|(L, R);
179
  L operator<<(L, R);
180
  L operator>>(L, R);
181
  ```
182
 
183
- where `LR` is the result of the usual arithmetic conversions between
184
- types `L` and `R`.
185
 
186
  For every triple (`L`, *vq*, `R`), where `L` is an arithmetic type, and
187
- `R` is a promoted arithmetic type, there exist candidate operator
188
- functions of the form
189
 
190
  ``` cpp
191
  vq L& operator=(vq L&, R);
192
  vq L& operator*=(vq L&, R);
193
  vq L& operator/=(vq L&, R);
@@ -200,12 +217,13 @@ operator functions of the form
200
 
201
  ``` cpp
202
  T*vq& operator=(T*vq&, T*);
203
  ```
204
 
205
- For every pair (`T`, *vq*), where `T` is an enumeration or pointer to
206
- member type, there exist candidate operator functions of the form
 
207
 
208
  ``` cpp
209
  vq T& operator=(vq T&, T);
210
  ```
211
 
@@ -237,19 +255,20 @@ There also exist candidate operator functions of the form
237
  bool operator!(bool);
238
  bool operator&&(bool, bool);
239
  bool operator||(bool, bool);
240
  ```
241
 
242
- For every pair of promoted arithmetic types `L` and `R`, there exist
243
- candidate operator functions of the form
 
244
 
245
  ``` cpp
246
  LR operator?:(bool, L, R);
247
  ```
248
 
249
- where `LR` is the result of the usual arithmetic conversions between
250
- types `L` and `R`.
251
 
252
  [*Note 3*: As with all these descriptions of candidate functions, this
253
  declaration serves only to describe the built-in operator for purposes
254
  of overload resolution. The operator “`?:`” cannot be
255
  overloaded. — *end note*]
@@ -259,167 +278,5 @@ enumeration type, there exist candidate operator functions of the form
259
 
260
  ``` cpp
261
  T operator?:(bool, T, T);
262
  ```
263
 
264
- <!-- Link reference definitions -->
265
- [basic.lookup]: basic.md#basic.lookup
266
- [basic.lookup.argdep]: basic.md#basic.lookup.argdep
267
- [basic.stc.dynamic]: basic.md#basic.stc.dynamic
268
- [class.access]: class.md#class.access
269
- [class.conv]: special.md#class.conv
270
- [class.conv.ctor]: special.md#class.conv.ctor
271
- [class.conv.fct]: special.md#class.conv.fct
272
- [class.copy]: special.md#class.copy
273
- [class.friend]: class.md#class.friend
274
- [class.member.lookup]: class.md#class.member.lookup
275
- [class.mfct]: class.md#class.mfct
276
- [class.static]: class.md#class.static
277
- [class.this]: class.md#class.this
278
- [conv]: conv.md#conv
279
- [conv.array]: conv.md#conv.array
280
- [conv.bool]: conv.md#conv.bool
281
- [conv.double]: conv.md#conv.double
282
- [conv.fctptr]: conv.md#conv.fctptr
283
- [conv.fpint]: conv.md#conv.fpint
284
- [conv.fpprom]: conv.md#conv.fpprom
285
- [conv.func]: conv.md#conv.func
286
- [conv.integral]: conv.md#conv.integral
287
- [conv.lval]: conv.md#conv.lval
288
- [conv.mem]: conv.md#conv.mem
289
- [conv.prom]: conv.md#conv.prom
290
- [conv.ptr]: conv.md#conv.ptr
291
- [conv.qual]: conv.md#conv.qual
292
- [cpp]: cpp.md#cpp
293
- [dcl.array]: dcl.md#dcl.array
294
- [dcl.fct]: dcl.md#dcl.fct
295
- [dcl.fct.def.delete]: dcl.md#dcl.fct.def.delete
296
- [dcl.fct.default]: dcl.md#dcl.fct.default
297
- [dcl.init]: dcl.md#dcl.init
298
- [dcl.init.aggr]: dcl.md#dcl.init.aggr
299
- [dcl.init.list]: dcl.md#dcl.init.list
300
- [dcl.init.ref]: dcl.md#dcl.init.ref
301
- [dcl.init.string]: dcl.md#dcl.init.string
302
- [dcl.typedef]: dcl.md#dcl.typedef
303
- [except.spec]: except.md#except.spec
304
- [expr]: expr.md#expr
305
- [expr.ass]: expr.md#expr.ass
306
- [expr.call]: expr.md#expr.call
307
- [expr.cast]: expr.md#expr.cast
308
- [expr.cond]: expr.md#expr.cond
309
- [expr.mptr.oper]: expr.md#expr.mptr.oper
310
- [expr.prim]: expr.md#expr.prim
311
- [expr.static.cast]: expr.md#expr.static.cast
312
- [expr.sub]: expr.md#expr.sub
313
- [expr.type.conv]: expr.md#expr.type.conv
314
- [expr.unary.op]: expr.md#expr.unary.op
315
- [lex.ext]: lex.md#lex.ext
316
- [namespace.udecl]: dcl.md#namespace.udecl
317
- [over]: #over
318
- [over.ass]: #over.ass
319
- [over.best.ics]: #over.best.ics
320
- [over.binary]: #over.binary
321
- [over.built]: #over.built
322
- [over.call]: #over.call
323
- [over.call.func]: #over.call.func
324
- [over.call.object]: #over.call.object
325
- [over.dcl]: #over.dcl
326
- [over.ics.ellipsis]: #over.ics.ellipsis
327
- [over.ics.list]: #over.ics.list
328
- [over.ics.rank]: #over.ics.rank
329
- [over.ics.ref]: #over.ics.ref
330
- [over.ics.scs]: #over.ics.scs
331
- [over.ics.user]: #over.ics.user
332
- [over.inc]: #over.inc
333
- [over.literal]: #over.literal
334
- [over.load]: #over.load
335
- [over.match]: #over.match
336
- [over.match.best]: #over.match.best
337
- [over.match.call]: #over.match.call
338
- [over.match.class.deduct]: #over.match.class.deduct
339
- [over.match.conv]: #over.match.conv
340
- [over.match.copy]: #over.match.copy
341
- [over.match.ctor]: #over.match.ctor
342
- [over.match.funcs]: #over.match.funcs
343
- [over.match.list]: #over.match.list
344
- [over.match.oper]: #over.match.oper
345
- [over.match.ref]: #over.match.ref
346
- [over.match.viable]: #over.match.viable
347
- [over.oper]: #over.oper
348
- [over.over]: #over.over
349
- [over.ref]: #over.ref
350
- [over.sub]: #over.sub
351
- [over.unary]: #over.unary
352
- [stmt.return]: stmt.md#stmt.return
353
- [tab:over.conversions]: #tab:over.conversions
354
- [tab:over.rel.op.func]: #tab:over.rel.op.func
355
- [temp.arg.explicit]: temp.md#temp.arg.explicit
356
- [temp.arg.nontype]: temp.md#temp.arg.nontype
357
- [temp.deduct]: temp.md#temp.deduct
358
- [temp.deduct.funcaddr]: temp.md#temp.deduct.funcaddr
359
- [temp.func.order]: temp.md#temp.func.order
360
- [temp.over]: temp.md#temp.over
361
- [temp.variadic]: temp.md#temp.variadic
362
- [usrlit.suffix]: library.md#usrlit.suffix
363
-
364
- [^1]: When a parameter type includes a function type, such as in the
365
- case of a parameter type that is a pointer to function, the `const`
366
- and `volatile` type-specifiers at the outermost level of the
367
- parameter type specifications for the inner function type are also
368
- ignored.
369
-
370
- [^2]: The process of argument deduction fully determines the parameter
371
- types of the function template specializations, i.e., the parameters
372
- of function template specializations contain no template parameter
373
- types. Therefore, except where specified otherwise, function
374
- template specializations and non-template functions ([[dcl.fct]])
375
- are treated equivalently for the remainder of overload resolution.
376
-
377
- [^3]: Note that cv-qualifiers on the type of objects are significant in
378
- overload resolution for both glvalue and class prvalue objects.
379
-
380
- [^4]: An implied object argument must be contrived to correspond to the
381
- implicit object parameter attributed to member functions during
382
- overload resolution. It is not used in the call to the selected
383
- function. Since the member functions all have the same implicit
384
- object parameter, the contrived object will not be the cause to
385
- select or reject a function.
386
-
387
- [^5]: Note that this construction can yield candidate call functions
388
- that cannot be differentiated one from the other by overload
389
- resolution because they have identical declarations or differ only
390
- in their return type. The call will be ambiguous if overload
391
- resolution cannot select a match to the call that is uniquely better
392
- than such undifferentiable functions.
393
-
394
- [^6]: If the set of candidate functions is empty, overload resolution is
395
- unsuccessful.
396
-
397
- [^7]: If the value returned by the `operator->` function has class type,
398
- this may result in selecting and calling another `operator->`
399
- function. The process repeats until an `operator->` function returns
400
- a value of non-class type.
401
-
402
- [^8]: According to  [[dcl.fct.default]], parameters following the
403
- *(m+1)*-st parameter must also have default arguments.
404
-
405
- [^9]: If a function is a static member function, this definition means
406
- that the first argument, the implied object argument, has no effect
407
- in the determination of whether the function is better or worse than
408
- any other function.
409
-
410
- [^10]: The algorithm for selecting the best viable function is linear in
411
- the number of viable functions. Run a simple tournament to find a
412
- function `W` that is not worse than any opponent it faced. Although
413
- another function `F` that `W` did not face might be at least as good
414
- as `W`, `F` cannot be the best function because at some point in the
415
- tournament `F` encountered another function `G` such that `F` was
416
- not better than `G`. Hence, `W` is either the best function or there
417
- is no best function. So, make a second pass over the viable
418
- functions to verify that `W` is better than all other functions.
419
-
420
- [^11]: Since there are no parameters of array type, this will only occur
421
- as the referenced type of a reference parameter.
422
-
423
- [^12]: Calling `operator++` explicitly, as in expressions like
424
- `a.operator++(2)`, has no special properties: The argument to
425
- `operator++` is `2`.
 
1
  ## Built-in operators <a id="over.built">[[over.built]]</a>
2
 
3
  The candidate operator functions that represent the built-in operators
4
+ defined in [[expr.compound]] are specified in this subclause. These
5
  candidate functions participate in the operator overload resolution
6
  process as described in  [[over.match.oper]] and are used for no other
7
  purpose.
8
 
9
  [*Note 1*: Because built-in operators take only operands with non-class
 
15
  that can be converted to a type appropriate for the operator. Also note
16
  that some of the candidate operator functions given in this subclause
17
  are more permissive than the built-in operators themselves. As described
18
  in  [[over.match.oper]], after a built-in operator is selected by
19
  overload resolution the expression is subject to the requirements for
20
+ the built-in operator given in [[expr.compound]], and therefore to any
21
  additional semantic constraints given there. If there is a user-written
22
  candidate with the same name and parameter types as a built-in candidate
23
  operator function, the built-in operator function is hidden and is not
24
  included in the set of candidate functions. — *end note*]
25
 
26
  In this subclause, the term *promoted integral type* is used to refer to
27
+ those integral types which are preserved by integral promotion
28
+ [[conv.prom]] (including e.g. `int` and `long` but excluding e.g.
29
+ `char`).
 
30
 
31
+ [*Note 2*: In all cases where a promoted integral type is required, an
32
+ operand of unscoped enumeration type will be acceptable by way of the
33
+ integral promotions. — *end note*]
34
 
35
+ In the remainder of this subclause, *vq* represents either `volatile` or
36
  no cv-qualifier.
37
 
38
  For every pair (`T`, *vq*), where `T` is an arithmetic type other than
39
  `bool`, there exist candidate operator functions of the form
40
 
 
80
 
81
  ``` cpp
82
  T* operator+(T*);
83
  ```
84
 
85
+ For every floating-point or promoted integral type `T`, there exist
86
+ candidate operator functions of the form
87
 
88
  ``` cpp
89
  T operator+(T);
90
  T operator-(T);
91
  ```
 
108
 
109
  where *cv12* is the union of *cv1* and *cv2*. The return type is shown
110
  for exposition only; see  [[expr.mptr.oper]] for the determination of
111
  the operator’s result type.
112
 
113
+ For every pair of types `L` and `R`, where each of `L` and `R` is a
114
+ floating-point or promoted integral type, there exist candidate operator
115
+ functions of the form
116
 
117
  ``` cpp
118
  LR operator*(L, R);
119
  LR operator/(L, R);
120
  LR operator+(L, R);
121
  LR operator-(L, R);
122
+ bool operator==(L, R);
123
+ bool operator!=(L, R);
124
  bool operator<(L, R);
125
  bool operator>(L, R);
126
  bool operator<=(L, R);
127
  bool operator>=(L, R);
 
 
128
  ```
129
 
130
+ where `LR` is the result of the usual arithmetic conversions
131
+ [[expr.arith.conv]] between types `L` and `R`.
132
+
133
+ For every integral type `T` there exists a candidate operator function
134
+ of the form
135
+
136
+ ``` cpp
137
+ std::strong_ordering operator<=>(T, T);
138
+ ```
139
+
140
+ For every pair of floating-point types `L` and `R`, there exists a
141
+ candidate operator function of the form
142
+
143
+ ``` cpp
144
+ std::partial_ordering operator<=>(L, R);
145
+ ```
146
 
147
  For every cv-qualified or cv-unqualified object type `T` there exist
148
  candidate operator functions of the form
149
 
150
  ``` cpp
 
164
 
165
  For every `T`, where `T` is an enumeration type or a pointer type, there
166
  exist candidate operator functions of the form
167
 
168
  ``` cpp
169
+ bool operator==(T, T);
170
+ bool operator!=(T, T);
171
  bool operator<(T, T);
172
  bool operator>(T, T);
173
  bool operator<=(T, T);
174
  bool operator>=(T, T);
175
+ R operator<=>(T, T);
 
176
  ```
177
 
178
+ where `R` is the result type specified in [[expr.spaceship]].
179
+
180
+ For every `T`, where `T` is a pointer-to-member type or
181
+ `std::nullptr_t`, there exist candidate operator functions of the form
182
 
183
  ``` cpp
184
  bool operator==(T, T);
185
  bool operator!=(T, T);
186
  ```
 
195
  LR operator|(L, R);
196
  L operator<<(L, R);
197
  L operator>>(L, R);
198
  ```
199
 
200
+ where `LR` is the result of the usual arithmetic conversions
201
+ [[expr.arith.conv]] between types `L` and `R`.
202
 
203
  For every triple (`L`, *vq*, `R`), where `L` is an arithmetic type, and
204
+ `R` is a floating-point or promoted integral type, there exist candidate
205
+ operator functions of the form
206
 
207
  ``` cpp
208
  vq L& operator=(vq L&, R);
209
  vq L& operator*=(vq L&, R);
210
  vq L& operator/=(vq L&, R);
 
217
 
218
  ``` cpp
219
  T*vq& operator=(T*vq&, T*);
220
  ```
221
 
222
+ For every pair (`T`, *vq*), where `T` is an enumeration or
223
+ pointer-to-member type, there exist candidate operator functions of the
224
+ form
225
 
226
  ``` cpp
227
  vq T& operator=(vq T&, T);
228
  ```
229
 
 
255
  bool operator!(bool);
256
  bool operator&&(bool, bool);
257
  bool operator||(bool, bool);
258
  ```
259
 
260
+ For every pair of types `L` and `R`, where each of `L` and `R` is a
261
+ floating-point or promoted integral type, there exist candidate operator
262
+ functions of the form
263
 
264
  ``` cpp
265
  LR operator?:(bool, L, R);
266
  ```
267
 
268
+ where `LR` is the result of the usual arithmetic conversions
269
+ [[expr.arith.conv]] between types `L` and `R`.
270
 
271
  [*Note 3*: As with all these descriptions of candidate functions, this
272
  declaration serves only to describe the built-in operator for purposes
273
  of overload resolution. The operator “`?:`” cannot be
274
  overloaded. — *end note*]
 
278
 
279
  ``` cpp
280
  T operator?:(bool, T, T);
281
  ```
282