From Jason Turner

[basic.types]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpo7q7ap9w/{from.md → to.md} +240 -94
tmp/tmpo7q7ap9w/{from.md → to.md} RENAMED
@@ -10,11 +10,11 @@ functions [[dcl.fct]]. — *end note*]
10
 
11
  For any object (other than a potentially-overlapping subobject) of
12
  trivially copyable type `T`, whether or not the object holds a valid
13
  value of type `T`, the underlying bytes [[intro.memory]] making up the
14
  object can be copied into an array of `char`, `unsigned char`, or
15
- `std::byte` [[cstddef.syn]].[^14]
16
 
17
  If the content of that array is copied back into the object, the object
18
  shall subsequently hold its original value.
19
 
20
  [*Example 1*:
@@ -30,11 +30,11 @@ std::memcpy(&obj, buf, N); // at this point, each subobject of obj of scala
30
  — *end example*]
31
 
32
  For two distinct objects `obj1` and `obj2` of trivially copyable type
33
  `T`, where neither `obj1` nor `obj2` is a potentially-overlapping
34
  subobject, if the underlying bytes [[intro.memory]] making up `obj1` are
35
- copied into `obj2`,[^15]
36
 
37
  `obj2` shall subsequently hold the same value as `obj1`.
38
 
39
  [*Example 2*:
40
 
@@ -47,23 +47,31 @@ std::memcpy(t1p, t2p, sizeof(T));
47
  // the same value as the corresponding subobject in *t2p
48
  ```
49
 
50
  — *end example*]
51
 
52
- The *object representation* of an object of type `T` is the sequence of
53
- *N* `unsigned char` objects taken up by the object of type `T`, where
54
- *N* equals `sizeof(T)`. The *value representation* of an object of type
55
- `T` is the set of bits that participate in representing a value of type
56
- `T`. Bits in the object representation that are not part of the value
57
- representation are *padding bits*. For trivially copyable types, the
58
- value representation is a set of bits in the object representation that
59
- determines a *value*, which is one discrete element of an
60
- *implementation-defined* set of values.[^16]
 
 
 
 
 
 
 
 
61
 
62
  A class that has been declared but not defined, an enumeration type in
63
  certain contexts [[dcl.enum]], or an array of unknown bound or of
64
- incomplete element type, is an *incompletely-defined object type*.[^17]
65
 
66
  Incompletely-defined object types and cv `void` are *incomplete types*
67
  [[basic.fundamental]].
68
 
69
  [*Note 2*: Objects cannot be defined to have an incomplete type
@@ -121,34 +129,36 @@ contexts incomplete types are prohibited. — *end note*]
121
 
122
  An *object type* is a (possibly cv-qualified) type that is not a
123
  function type, not a reference type, and not cv `void`.
124
 
125
  Arithmetic types [[basic.fundamental]], enumeration types, pointer
126
- types, pointer-to-member types [[basic.compound]], `std::nullptr_t`, and
127
- cv-qualified [[basic.type.qualifier]] versions of these types are
128
- collectively called *scalar types*. Scalar types, trivially copyable
129
- class types [[class.prop]], arrays of such types, and cv-qualified
130
- versions of these types are collectively called *trivially copyable
131
- types*. Scalar types, trivial class types [[class.prop]], arrays of such
132
- types and cv-qualified versions of these types are collectively called
133
- *trivial types*. Scalar types, standard-layout class types
134
- [[class.prop]], arrays of such types and cv-qualified versions of these
135
- types are collectively called *standard-layout types*. Scalar types,
136
- implicit-lifetime class types [[class.prop]], array types, and
137
- cv-qualified versions of these types are collectively called
138
- *implicit-lifetime types*.
 
 
139
 
140
  A type is a *literal type* if it is:
141
 
142
  - cv `void`; or
143
  - a scalar type; or
144
  - a reference type; or
145
  - an array of literal type; or
146
  - a possibly cv-qualified class type [[class]] that has all of the
147
  following properties:
148
  - it has a constexpr destructor [[dcl.constexpr]],
149
- - all of its non-static non-variant data members and base classes are
150
  of non-volatile literal types, and
151
  - it
152
  - is a closure type [[expr.prim.lambda.closure]],
153
  - is an aggregate union type that has either no variant members or
154
  at least one variant member of non-volatile literal type,
@@ -168,20 +178,30 @@ expression. — *end note*]
168
  Two types *cv1* `T1` and *cv2* `T2` are *layout-compatible types* if
169
  `T1` and `T2` are the same type, layout-compatible enumerations
170
  [[dcl.enum]], or layout-compatible standard-layout class types
171
  [[class.mem]].
172
 
 
 
 
 
 
 
 
 
 
 
173
  ### Fundamental types <a id="basic.fundamental">[[basic.fundamental]]</a>
174
 
175
  There are five *standard signed integer types*: “`signed char`”,
176
  “`short int`”, “`int`”, “`long int`”, and “`long long int`”. In this
177
  list, each type provides at least as much storage as those preceding it
178
  in the list. There may also be *implementation-defined* *extended signed
179
  integer types*. The standard and extended signed integer types are
180
  collectively called *signed integer types*. The range of representable
181
- values for a signed integer type is -2ᴺ⁻¹ to 2ᴺ⁻¹-1 (inclusive), where
182
- *N* is called the *width* of the type.
183
 
184
  [*Note 1*: Plain `int`s are intended to have the natural width
185
  suggested by the architecture of the execution environment; the other
186
  signed integer types are provided to meet special needs. — *end note*]
187
 
@@ -203,11 +223,11 @@ arithmetic yields undefined behavior [[expr.pre]]. — *end note*]
203
  An unsigned integer type has the same object representation, value
204
  representation, and alignment requirements [[basic.align]] as the
205
  corresponding signed integer type. For each value x of a signed integer
206
  type, the value of the corresponding unsigned integer type congruent to
207
  x modulo 2ᴺ has the same value of corresponding bits in its value
208
- representation.[^18]
209
 
210
  [*Example 1*: The value -1 of a signed integer type has the same
211
  representation as the largest value of the corresponding unsigned
212
  type. — *end example*]
213
 
@@ -220,22 +240,22 @@ type. — *end example*]
220
  | `int` | 16 |
221
  | `long int` | 32 |
222
  | `long long int` | 64 |
223
 
224
 
225
- The width of each signed integer type shall not be less than the values
226
- specified in [[basic.fundamental.width]]. The value representation of a
227
- signed or unsigned integer type comprises N bits, where N is the
228
- respective width. Each set of values for any padding bits
229
  [[basic.types.general]] in the object representation are alternative
230
  representations of the value specified by the value representation.
231
 
232
  [*Note 3*: Padding bits have unspecified value, but cannot cause traps.
233
- In contrast, see ISO C 6.2.6.2. — *end note*]
234
 
235
  [*Note 4*: The signed and unsigned integer types satisfy the
236
- constraints given in ISO C 5.2.4.2.1. — *end note*]
237
 
238
  Except as specified above, the width of a signed or unsigned integer
239
  type is *implementation-defined*.
240
 
241
  Each value x of an unsigned integer type with width N has a unique
@@ -273,12 +293,12 @@ than the width of that type has padding bits; see
273
  Type `wchar_t` is a distinct type that has an *implementation-defined*
274
  signed or unsigned integer type as its underlying type.
275
 
276
  Type `char8_t` denotes a distinct type whose underlying type is
277
  `unsigned char`. Types `char16_t` and `char32_t` denote distinct types
278
- whose underlying types are `uint_least16_t` and `uint_least32_t`,
279
- respectively, in `<cstdint>`.
280
 
281
  Type `bool` is a distinct type that has the same object representation,
282
  value representation, and alignment requirements as an
283
  *implementation-defined* unsigned integer type. The values of type
284
  `bool` are `true` and `false`.
@@ -318,128 +338,233 @@ interactions with floating-point types. — *end note*]
318
 
319
  Except as specified in [[basic.extended.fp]], the object and value
320
  representations and accuracy of operations of floating-point types are
321
  *implementation-defined*.
322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  Integral and floating-point types are collectively termed *arithmetic
324
  types*.
325
 
326
- [*Note 10*: Properties of the arithmetic types, such as their minimum
327
  and maximum representable value, can be queried using the facilities in
328
  the standard library headers `<limits>`, `<climits>`, and
329
  `<cfloat>`. — *end note*]
330
 
331
  A type cv `void` is an incomplete type that cannot be completed; such a
332
  type has an empty set of values. It is used as the return type for
333
- functions that do not return a value. Any expression can be explicitly
334
- converted to type cv `void`
335
- [[expr.type.conv]], [[expr.static.cast]], [[expr.cast]]. An expression
336
- of type cv `void` shall be used only as an expression statement
337
- [[stmt.expr]], as an operand of a comma expression [[expr.comma]], as a
338
- second or third operand of `?:` [[expr.cond]], as the operand of
339
- `typeid`, `noexcept`, or `decltype`, as the expression in a `return`
340
- statement [[stmt.return]] for a function with the return type cv `void`,
341
- or as the operand of an explicit conversion to type cv `void`.
342
-
343
- A value of type `std::nullptr_t` is a null pointer constant
344
- [[conv.ptr]]. Such values participate in the pointer and the
345
- pointer-to-member conversions [[conv.ptr]], [[conv.mem]].
346
- `sizeof(std::nullptr_t)` shall be equal to `sizeof(void*)`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
 
348
  The types described in this subclause are called *fundamental types*.
349
 
350
- [*Note 11*: Even if the implementation defines two or more fundamental
351
  types to have the same value representation, they are nevertheless
352
  different types. — *end note*]
353
 
354
  ### Optional extended floating-point types <a id="basic.extended.fp">[[basic.extended.fp]]</a>
355
 
356
  If the implementation supports an extended floating-point type
357
- [[basic.fundamental]] whose properties are specified by the ISO/IEC/IEEE
358
  60559 floating-point interchange format binary16, then the
359
- *typedef-name* `std::float16_t` is defined in the header `<stdfloat>`
360
  and names such a type, the macro `__STDCPP_FLOAT16_T__` is defined
361
  [[cpp.predefined]], and the floating-point literal suffixes `f16` and
362
  `F16` are supported [[lex.fcon]].
363
 
364
  If the implementation supports an extended floating-point type whose
365
- properties are specified by the ISO/IEC/IEEE 60559 floating-point
366
- interchange format binary32, then the *typedef-name* `std::float32_t` is
367
- defined in the header `<stdfloat>` and names such a type, the macro
368
  `__STDCPP_FLOAT32_T__` is defined, and the floating-point literal
369
  suffixes `f32` and `F32` are supported.
370
 
371
  If the implementation supports an extended floating-point type whose
372
- properties are specified by the ISO/IEC/IEEE 60559 floating-point
373
- interchange format binary64, then the *typedef-name* `std::float64_t` is
374
- defined in the header `<stdfloat>` and names such a type, the macro
375
  `__STDCPP_FLOAT64_T__` is defined, and the floating-point literal
376
  suffixes `f64` and `F64` are supported.
377
 
378
  If the implementation supports an extended floating-point type whose
379
- properties are specified by the ISO/IEC/IEEE 60559 floating-point
380
- interchange format binary128, then the *typedef-name* `std::float128_t`
381
- is defined in the header `<stdfloat>` and names such a type, the macro
382
  `__STDCPP_FLOAT128_T__` is defined, and the floating-point literal
383
  suffixes `f128` and `F128` are supported.
384
 
385
  If the implementation supports an extended floating-point type with the
386
- properties, as specified by ISO/IEC/IEEE 60559, of radix (b) of 2,
387
- storage width in bits (k) of 16, precision in bits (p) of 8, maximum
388
- exponent (emax) of 127, and exponent field width in bits (w) of 8, then
389
- the *typedef-name* `std::bfloat16_t` is defined in the header
390
- `<stdfloat>` and names such a type, the macro `__STDCPP_BFLOAT16_T__` is
391
- defined, and the floating-point literal suffixes `bf16` and `BF16` are
392
- supported.
393
 
394
  [*Note 1*: A summary of the parameters for each type is given in
395
  [[basic.extended.fp]]. The precision p includes the implicit 1 bit at
396
- the beginning of the mantissa, so the storage used for the mantissa is
397
- p-1 bits. ISO/IEC/IEEE 60559 does not assign a name for a type having
398
- the parameters specified for `std::bfloat16_t`. — *end note*]
399
 
400
  **Table: Properties of named extended floating-point types** <a id="basic.extended.fp">[basic.extended.fp]</a>
401
 
402
  | Parameter | `float16_t` | `float32_t` | `float64_t` | `float128_t` | `bfloat16_t` |
403
  | --------------------------------- | ----------- | ----------- | ----------- | ------------ | ------------ |
404
- | ISO/IEC/IEEE 60559 name | binary16 | binary32 | binary64 | binary128 | |
405
  | $k$, storage width in bits | 16 | 32 | 64 | 128 | 16 |
406
  | $p$, precision in bits | 11 | 24 | 53 | 113 | 8 |
407
  | $emax$, maximum exponent | 15 | 127 | 1023 | 16383 | 127 |
408
  | $w$, exponent field width in bits | 5 | 8 | 11 | 15 | 8 |
409
 
410
 
411
  *Recommended practice:* Any names that the implementation provides for
412
  the extended floating-point types described in this subsection that are
413
- in addition to the names defined in the `<stdfloat>` header should be
414
  chosen to increase compatibility and interoperability with the
415
  interchange types `_Float16`, `_Float32`, `_Float64`, and `_Float128`
416
- defined in ISO/IEC TS 18661-3 and with future versions of the C
417
- standard.
418
 
419
  ### Compound types <a id="basic.compound">[[basic.compound]]</a>
420
 
421
  Compound types can be constructed in the following ways:
422
 
423
  - *arrays* of objects of a given type, [[dcl.array]];
424
  - *functions*, which have parameters of given types and return `void` or
425
- references or objects of a given type, [[dcl.fct]];
426
  - *pointers* to cv `void` or objects or functions (including static
427
  members of classes) of a given type, [[dcl.ptr]];
428
  - *references* to objects or functions of a given type, [[dcl.ref]].
429
  There are two types of references:
430
  - lvalue reference
431
  - rvalue reference
432
- - *classes* containing a sequence of objects of various types [[class]],
433
- a set of types, enumerations and functions for manipulating these
434
- objects [[class.mfct]], and a set of restrictions on the access to
435
  these entities [[class.access]];
436
  - *unions*, which are classes capable of containing objects of different
437
  types at different times, [[class.union]];
438
  - *enumerations*, which comprise a set of named constant values,
439
  [[dcl.enum]];
440
- - *pointers to non-static class members*,[^19] which identify members of
441
  a given type within objects of a given class, [[dcl.mptr]]. Pointers
442
  to data members and pointers to member functions are collectively
443
  called *pointer-to-member* types.
444
 
445
  These methods of constructing types can be applied recursively;
@@ -463,46 +588,59 @@ to as a “pointer to `T`”.
463
  “pointer to `X`”. — *end example*]
464
 
465
  Except for pointers to static members, text referring to “pointers” does
466
  not apply to pointers to members. Pointers to incomplete types are
467
  allowed although there are restrictions on what can be done with them
468
- [[basic.align]]. Every value of pointer type is one of the following:
 
469
 
470
  - a *pointer to* an object or function (the pointer is said to *point*
471
  to the object or function), or
472
  - a *pointer past the end of* an object [[expr.add]], or
473
  - the *null pointer value* for that type, or
474
  - an *invalid pointer value*.
475
 
476
  A value of a pointer type that is a pointer to or past the end of an
477
  object *represents the address* of the first byte in memory
478
- [[intro.memory]] occupied by the object[^20]
479
 
480
  or the first byte in memory after the end of the storage occupied by the
481
  object, respectively.
482
 
483
  [*Note 2*: A pointer past the end of an object [[expr.add]] is not
484
  considered to point to an unrelated object of the object’s type, even if
485
- the unrelated object is located at that address. A pointer value becomes
486
- invalid when the storage it denotes reaches the end of its storage
487
- duration; see [[basic.stc]]. — *end note*]
488
 
489
  For purposes of pointer arithmetic [[expr.add]] and comparison
490
  [[expr.rel]], [[expr.eq]], a pointer past the end of the last element of
491
  an array `x` of n elements is considered to be equivalent to a pointer
492
- to a hypothetical array element n of `x` and an object of type `T` that
493
  is not an array element is considered to belong to an array with one
494
  element of type `T`. The value representation of pointer types is
495
  *implementation-defined*. Pointers to layout-compatible types shall have
496
  the same value representation and alignment requirements
497
  [[basic.align]].
498
 
499
  [*Note 3*: Pointers to over-aligned types [[basic.align]] have no
500
  special representation, but their range of valid values is restricted by
501
  the extended alignment requirement. — *end note*]
502
 
503
- Two objects *a* and *b* are *pointer-interconvertible* if:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
 
505
  - they are the same object, or
506
  - one is a union object and the other is a non-static data member of
507
  that object [[class.union]], or
508
  - one is a standard-layout class object and the other is the first
@@ -514,11 +652,11 @@ Two objects *a* and *b* are *pointer-interconvertible* if:
514
 
515
  If two objects are pointer-interconvertible, then they have the same
516
  address, and it is possible to obtain a pointer to one from a pointer to
517
  the other via a `reinterpret_cast` [[expr.reinterpret.cast]].
518
 
519
- [*Note 4*: An array object and its first element are not
520
  pointer-interconvertible, even though they have the same
521
  address. — *end note*]
522
 
523
  A byte of storage *b* is *reachable through* a pointer value that points
524
  to an object *x* if there is an object *y*, pointer-interconvertible
@@ -535,11 +673,11 @@ alignment requirements as an object of type “pointer to cv `char`”.
535
  Each type other than a function or reference type is part of a group of
536
  four distinct, but related, types: a *cv-unqualified* version, a
537
  *const-qualified* version, a *volatile-qualified* version, and a
538
  *const-volatile-qualified* version. The types in each such group shall
539
  have the same representation and alignment requirements
540
- [[basic.align]].[^21]
541
 
542
  A function or reference type is always cv-unqualified.
543
 
544
  - A *const object* is an object of type `const T` or a non-mutable
545
  subobject of a const object.
@@ -647,11 +785,11 @@ integral promotions [[conv.prom]] and the usual arithmetic conversions
647
  [[expr.arith.conv]]. — *end note*]
648
 
649
  Every floating-point type has a *floating-point conversion rank* defined
650
  as follows:
651
 
652
- - The rank of a floating point type `T` is greater than the rank of any
653
  floating-point type whose set of values is a proper subset of the set
654
  of values of `T`.
655
  - The rank of `long double` is greater than the rank of `double`, which
656
  is greater than the rank of `float`.
657
  - Two extended floating-point types with the same set of values have
@@ -659,11 +797,19 @@ as follows:
659
  - An extended floating-point type with the same set of values as exactly
660
  one cv-unqualified standard floating-point type has a rank equal to
661
  the rank of that standard floating-point type.
662
  - An extended floating-point type with the same set of values as more
663
  than one cv-unqualified standard floating-point type has a rank equal
664
- to the rank of `double`.
 
 
 
 
 
 
 
 
665
 
666
  [*Note 2*: The conversion ranks of floating-point types `T1` and `T2`
667
  are unordered if the set of values of `T1` is neither a subset nor a
668
  superset of the set of values of `T2`. This can happen when one type has
669
  both a larger range and a lower precision than the other. — *end note*]
 
10
 
11
  For any object (other than a potentially-overlapping subobject) of
12
  trivially copyable type `T`, whether or not the object holds a valid
13
  value of type `T`, the underlying bytes [[intro.memory]] making up the
14
  object can be copied into an array of `char`, `unsigned char`, or
15
+ `std::byte` [[cstddef.syn]].[^12]
16
 
17
  If the content of that array is copied back into the object, the object
18
  shall subsequently hold its original value.
19
 
20
  [*Example 1*:
 
30
  — *end example*]
31
 
32
  For two distinct objects `obj1` and `obj2` of trivially copyable type
33
  `T`, where neither `obj1` nor `obj2` is a potentially-overlapping
34
  subobject, if the underlying bytes [[intro.memory]] making up `obj1` are
35
+ copied into `obj2`,[^13]
36
 
37
  `obj2` shall subsequently hold the same value as `obj1`.
38
 
39
  [*Example 2*:
40
 
 
47
  // the same value as the corresponding subobject in *t2p
48
  ```
49
 
50
  — *end example*]
51
 
52
+ The *object representation* of a complete object type `T` is the
53
+ sequence of *N* `unsigned char` objects taken up by a non-bit-field
54
+ complete object of type `T`, where *N* equals `sizeof(T)`. The *value
55
+ representation* of a type `T` is the set of bits in the object
56
+ representation of `T` that participate in representing a value of type
57
+ `T`. The object and value representation of a non-bit-field complete
58
+ object of type `T` are the bytes and bits, respectively, of the object
59
+ corresponding to the object and value representation of its type. The
60
+ object representation of a bit-field object is the sequence of *N* bits
61
+ taken up by the object, where *N* is the width of the bit-field
62
+ [[class.bit]]. The value representation of a bit-field object is the set
63
+ of bits in the object representation that participate in representing
64
+ its value. Bits in the object representation of a type or object that
65
+ are not part of the value representation are *padding bits*. For
66
+ trivially copyable types, the value representation is a set of bits in
67
+ the object representation that determines a *value*, which is one
68
+ discrete element of an *implementation-defined* set of values.[^14]
69
 
70
  A class that has been declared but not defined, an enumeration type in
71
  certain contexts [[dcl.enum]], or an array of unknown bound or of
72
+ incomplete element type, is an *incompletely-defined object type*.[^15]
73
 
74
  Incompletely-defined object types and cv `void` are *incomplete types*
75
  [[basic.fundamental]].
76
 
77
  [*Note 2*: Objects cannot be defined to have an incomplete type
 
129
 
130
  An *object type* is a (possibly cv-qualified) type that is not a
131
  function type, not a reference type, and not cv `void`.
132
 
133
  Arithmetic types [[basic.fundamental]], enumeration types, pointer
134
+ types, pointer-to-member types [[basic.compound]], `std::meta::{}info`,
135
+ `std::nullptr_t`, and cv-qualified [[basic.type.qualifier]] versions of
136
+ these types are collectively called *scalar types*. Scalar types,
137
+ trivially copyable class types [[class.prop]], arrays of such types, and
138
+ cv-qualified versions of these types are collectively called *trivially
139
+ copyable types*. Scalar types, trivially relocatable class types
140
+ [[class.prop]], arrays of such types, and cv-qualified versions of these
141
+ types are collectively called *trivially relocatable types*.
142
+ Cv-unqualified scalar types, replaceable class types [[class.prop]], and
143
+ arrays of such types are collectively called *replaceable types*. Scalar
144
+ types, standard-layout class types [[class.prop]], arrays of such types,
145
+ and cv-qualified versions of these types are collectively called
146
+ *standard-layout types*. Scalar types, implicit-lifetime class types
147
+ [[class.prop]], array types, and cv-qualified versions of these types
148
+ are collectively called *implicit-lifetime types*.
149
 
150
  A type is a *literal type* if it is:
151
 
152
  - cv `void`; or
153
  - a scalar type; or
154
  - a reference type; or
155
  - an array of literal type; or
156
  - a possibly cv-qualified class type [[class]] that has all of the
157
  following properties:
158
  - it has a constexpr destructor [[dcl.constexpr]],
159
+ - all of its non-variant non-static data members and base classes are
160
  of non-volatile literal types, and
161
  - it
162
  - is a closure type [[expr.prim.lambda.closure]],
163
  - is an aggregate union type that has either no variant members or
164
  at least one variant member of non-volatile literal type,
 
178
  Two types *cv1* `T1` and *cv2* `T2` are *layout-compatible types* if
179
  `T1` and `T2` are the same type, layout-compatible enumerations
180
  [[dcl.enum]], or layout-compatible standard-layout class types
181
  [[class.mem]].
182
 
183
+ A type is *consteval-only* if it is either `std::meta::info` or a type
184
+ compounded from a consteval-only type [[basic.compound]]. Every object
185
+ of consteval-only type shall be
186
+
187
+ - the object associated with a constexpr variable or a subobject
188
+ thereof,
189
+ - a template parameter object [[temp.param]] or a subobject thereof, or
190
+ - an object whose lifetime begins and ends during the evaluation of a
191
+ core constant expression.
192
+
193
  ### Fundamental types <a id="basic.fundamental">[[basic.fundamental]]</a>
194
 
195
  There are five *standard signed integer types*: “`signed char`”,
196
  “`short int`”, “`int`”, “`long int`”, and “`long long int`”. In this
197
  list, each type provides at least as much storage as those preceding it
198
  in the list. There may also be *implementation-defined* *extended signed
199
  integer types*. The standard and extended signed integer types are
200
  collectively called *signed integer types*. The range of representable
201
+ values for a signed integer type is -2ᴺ⁻¹ to 2ᴺ⁻¹-1 (inclusive), where N
202
+ is called the *width* of the type.
203
 
204
  [*Note 1*: Plain `int`s are intended to have the natural width
205
  suggested by the architecture of the execution environment; the other
206
  signed integer types are provided to meet special needs. — *end note*]
207
 
 
223
  An unsigned integer type has the same object representation, value
224
  representation, and alignment requirements [[basic.align]] as the
225
  corresponding signed integer type. For each value x of a signed integer
226
  type, the value of the corresponding unsigned integer type congruent to
227
  x modulo 2ᴺ has the same value of corresponding bits in its value
228
+ representation.[^16]
229
 
230
  [*Example 1*: The value -1 of a signed integer type has the same
231
  representation as the largest value of the corresponding unsigned
232
  type. — *end example*]
233
 
 
240
  | `int` | 16 |
241
  | `long int` | 32 |
242
  | `long long int` | 64 |
243
 
244
 
245
+ The width of each standard signed integer type shall not be less than
246
+ the values specified in [[basic.fundamental.width]]. The value
247
+ representation of a signed or unsigned integer type comprises N bits,
248
+ where N is the respective width. Each set of values for any padding bits
249
  [[basic.types.general]] in the object representation are alternative
250
  representations of the value specified by the value representation.
251
 
252
  [*Note 3*: Padding bits have unspecified value, but cannot cause traps.
253
+ In contrast, see ISO/IEC 9899:2018 (C) 6.2.6.2. — *end note*]
254
 
255
  [*Note 4*: The signed and unsigned integer types satisfy the
256
+ constraints given in ISO/IEC 9899:2018 (C) 5.3.5.3.2. — *end note*]
257
 
258
  Except as specified above, the width of a signed or unsigned integer
259
  type is *implementation-defined*.
260
 
261
  Each value x of an unsigned integer type with width N has a unique
 
293
  Type `wchar_t` is a distinct type that has an *implementation-defined*
294
  signed or unsigned integer type as its underlying type.
295
 
296
  Type `char8_t` denotes a distinct type whose underlying type is
297
  `unsigned char`. Types `char16_t` and `char32_t` denote distinct types
298
+ whose underlying types are `std::uint_least16_t` and
299
+ `std::uint_least32_t`, respectively, in `<cstdint>`.
300
 
301
  Type `bool` is a distinct type that has the same object representation,
302
  value representation, and alignment requirements as an
303
  *implementation-defined* unsigned integer type. The values of type
304
  `bool` are `true` and `false`.
 
338
 
339
  Except as specified in [[basic.extended.fp]], the object and value
340
  representations and accuracy of operations of floating-point types are
341
  *implementation-defined*.
342
 
343
+ The minimum range of representable values for a floating-point type is
344
+ the most negative finite floating-point number representable in that
345
+ type through the most positive finite floating-point number
346
+ representable in that type. In addition, if negative infinity is
347
+ representable in a type, the range of that type is extended to all
348
+ negative real numbers; likewise, if positive infinity is representable
349
+ in a type, the range of that type is extended to all positive real
350
+ numbers.
351
+
352
+ [*Note 10*: Since negative and positive infinity are representable in
353
+ ISO/IEC 60559 formats, all real numbers lie within the range of
354
+ representable values of a floating-point type adhering to ISO/IEC
355
+ 60559. — *end note*]
356
+
357
  Integral and floating-point types are collectively termed *arithmetic
358
  types*.
359
 
360
+ [*Note 11*: Properties of the arithmetic types, such as their minimum
361
  and maximum representable value, can be queried using the facilities in
362
  the standard library headers `<limits>`, `<climits>`, and
363
  `<cfloat>`. — *end note*]
364
 
365
  A type cv `void` is an incomplete type that cannot be completed; such a
366
  type has an empty set of values. It is used as the return type for
367
+ functions that do not return a value. An expression of type cv `void`
368
+ shall be used only as
369
+
370
+ - an expression statement [[stmt.expr]],
371
+ - the expression in a `return` statement [[stmt.return]] for a function
372
+ with the return type cv `void`,
373
+ - an operand of a comma expression [[expr.comma]],
374
+ - the second or third operand of `?:` [[expr.cond]],
375
+ - the operand of a `typeid` expression [[expr.typeid]],
376
+ - the operand of a `noexcept` operator [[expr.unary.noexcept]],
377
+ - the operand of a `decltype` specifier [[dcl.type.decltype]], or
378
+ - the operand of an explicit conversion to type cv `void`
379
+ [[expr.type.conv]], [[expr.static.cast]], [[expr.cast]].
380
+
381
+ The types denoted by cv `std::nullptr_t` are distinct types. A prvalue
382
+ of type `std::nullptr_t` is a null pointer constant [[conv.ptr]]. Such
383
+ values participate in the pointer and the pointer-to-member conversions
384
+ [[conv.ptr]], [[conv.mem]]. `sizeof(std::nullptr_t)` shall be equal to
385
+ `sizeof(void*)`.
386
+
387
+ A value of type `std::meta::info` is called a *reflection*. There exists
388
+ a unique *null reflection*; every other reflection is a representation
389
+ of
390
+
391
+ - a value of scalar type [[temp.param]],
392
+ - an object with static storage duration [[basic.stc]],
393
+ - a variable [[basic.pre]],
394
+ - a structured binding [[dcl.struct.bind]],
395
+ - a function [[dcl.fct]],
396
+ - a function parameter,
397
+ - an enumerator [[dcl.enum]],
398
+ - an annotation [[dcl.attr.grammar]],
399
+ - a type alias [[dcl.typedef]],
400
+ - a type [[basic.types]],
401
+ - a class member [[class.mem]],
402
+ - an unnamed bit-field [[class.bit]],
403
+ - a class template [[temp.pre]],
404
+ - a function template,
405
+ - a variable template,
406
+ - an alias template [[temp.alias]],
407
+ - a concept [[temp.concept]],
408
+ - a namespace alias [[namespace.alias]],
409
+ - a namespace [[basic.namespace.general]],
410
+ - a direct base class relationship [[class.derived.general]], or
411
+ - a data member description [[class.mem.general]].
412
+
413
+ A reflection is said to *represent* the corresponding construct.
414
+
415
+ [*Note 12*: A reflection of a value can be produced by library
416
+ functions such as `std::meta::constant_of` and
417
+ `std::meta::reflect_constant`. — *end note*]
418
+
419
+ [*Example 2*:
420
+
421
+ ``` cpp
422
+ int arr[] = {1, 2, 3};
423
+ auto [a1, a2, a3] = arr;
424
+ [[=1]] void fn(int n);
425
+ enum Enum { A };
426
+ using Alias = int;
427
+ struct B {};
428
+ struct S : B {
429
+ int mem;
430
+ int : 0;
431
+ };
432
+ template<auto> struct TCls {};
433
+ template<auto> void TFn();
434
+ template<auto> int TVar;
435
+ template<auto N> using TAlias = TCls<N>;
436
+ template<auto> concept Concept = requires { true; };
437
+ namespace NS {};
438
+ namespace NSAlias = NS;
439
+
440
+ constexpr auto ctx = std::meta::access_context::current();
441
+
442
+ constexpr auto r1 = std::meta::reflect_constant(42); // represents int value of 42
443
+ constexpr auto r2 = std::meta::reflect_object(arr[1]); // represents int object
444
+ constexpr auto r3 = ^^arr; // represents a variable
445
+ constexpr auto r4 = ^^a3; // represents a structured binding
446
+ constexpr auto r5 = ^^fn; // represents a function
447
+ constexpr auto r6 = std::meta::parameters_of(^^fn)[0]; // represents a function parameter
448
+ constexpr auto r7 = ^^Enum::A; // represents an enumerator
449
+ constexpr auto r8 = std::meta::annotations_of(^^fn)[0]; // represents an annotation
450
+ constexpr auto r9 = ^^Alias; // represents a type alias
451
+ constexpr auto r10 = ^^S; // represents a type
452
+ constexpr auto r11 = ^^S::mem; // represents a class member
453
+ constexpr auto r12 = std::meta::members_of(^^S, ctx)[1]; // represents an unnamed bit-field
454
+ constexpr auto r13 = ^^TCls; // represents a class template
455
+ constexpr auto r14 = ^^TFn; // represents a function template
456
+ constexpr auto r15 = ^^TVar; // represents a variable template
457
+ constexpr auto r16 = ^^TAlias; // represents an alias template
458
+ constexpr auto r17 = ^^Concept; // represents a concept
459
+ constexpr auto r18 = ^^NSAlias; // represents a namespace alias
460
+ constexpr auto r19 = ^^NS; // represents a namespace
461
+ constexpr auto r20 = std::meta::bases_of(^^S, ctx)[0]; // represents a direct base class relationship
462
+ constexpr auto r21 =
463
+ std::meta::data_member_spec(^^int, {.name="member"}); // represents a data member description
464
+ ```
465
+
466
+ — *end example*]
467
+
468
+ *Recommended practice:* Implementations should not represent other
469
+ constructs specified in this document, such as *using-declarator*s,
470
+ partial template specializations, attributes, placeholder types,
471
+ statements, or expressions, as values of type `std::meta::info`.
472
+
473
+ [*Note 13*: Future revisions of this document can specify semantics for
474
+ reflections representing any such constructs. — *end note*]
475
 
476
  The types described in this subclause are called *fundamental types*.
477
 
478
+ [*Note 14*: Even if the implementation defines two or more fundamental
479
  types to have the same value representation, they are nevertheless
480
  different types. — *end note*]
481
 
482
  ### Optional extended floating-point types <a id="basic.extended.fp">[[basic.extended.fp]]</a>
483
 
484
  If the implementation supports an extended floating-point type
485
+ [[basic.fundamental]] whose properties are specified by the ISO/IEC
486
  60559 floating-point interchange format binary16, then the
487
+ *typedef-name* `std::float16_t` is declared in the header `<stdfloat>`
488
  and names such a type, the macro `__STDCPP_FLOAT16_T__` is defined
489
  [[cpp.predefined]], and the floating-point literal suffixes `f16` and
490
  `F16` are supported [[lex.fcon]].
491
 
492
  If the implementation supports an extended floating-point type whose
493
+ properties are specified by the ISO/IEC 60559 floating-point interchange
494
+ format binary32, then the *typedef-name* `std::float32_t` is declared in
495
+ the header `<stdfloat>` and names such a type, the macro
496
  `__STDCPP_FLOAT32_T__` is defined, and the floating-point literal
497
  suffixes `f32` and `F32` are supported.
498
 
499
  If the implementation supports an extended floating-point type whose
500
+ properties are specified by the ISO/IEC 60559 floating-point interchange
501
+ format binary64, then the *typedef-name* `std::float64_t` is declared in
502
+ the header `<stdfloat>` and names such a type, the macro
503
  `__STDCPP_FLOAT64_T__` is defined, and the floating-point literal
504
  suffixes `f64` and `F64` are supported.
505
 
506
  If the implementation supports an extended floating-point type whose
507
+ properties are specified by the ISO/IEC 60559 floating-point interchange
508
+ format binary128, then the *typedef-name* `std::float128_t` is declared
509
+ in the header `<stdfloat>` and names such a type, the macro
510
  `__STDCPP_FLOAT128_T__` is defined, and the floating-point literal
511
  suffixes `f128` and `F128` are supported.
512
 
513
  If the implementation supports an extended floating-point type with the
514
+ properties, as specified by ISO/IEC 60559, of radix (b) of 2, storage
515
+ width in bits (k) of 16, precision in bits (p) of 8, maximum exponent
516
+ (emax) of 127, and exponent field width in bits (w) of 8, then the
517
+ *typedef-name* `std::bfloat16_t` is declared in the header `<stdfloat>`
518
+ and names such a type, the macro `__STDCPP_BFLOAT16_T__` is defined, and
519
+ the floating-point literal suffixes `bf16` and `BF16` are supported.
 
520
 
521
  [*Note 1*: A summary of the parameters for each type is given in
522
  [[basic.extended.fp]]. The precision p includes the implicit 1 bit at
523
+ the beginning of the significand, so the storage used for the
524
+ significand is p-1 bits. ISO/IEC 60559 does not assign a name for a type
525
+ having the parameters specified for `std::bfloat16_t`. — *end note*]
526
 
527
  **Table: Properties of named extended floating-point types** <a id="basic.extended.fp">[basic.extended.fp]</a>
528
 
529
  | Parameter | `float16_t` | `float32_t` | `float64_t` | `float128_t` | `bfloat16_t` |
530
  | --------------------------------- | ----------- | ----------- | ----------- | ------------ | ------------ |
531
+ | ISO/IEC 60559 name | binary16 | binary32 | binary64 | binary128 | |
532
  | $k$, storage width in bits | 16 | 32 | 64 | 128 | 16 |
533
  | $p$, precision in bits | 11 | 24 | 53 | 113 | 8 |
534
  | $emax$, maximum exponent | 15 | 127 | 1023 | 16383 | 127 |
535
  | $w$, exponent field width in bits | 5 | 8 | 11 | 15 | 8 |
536
 
537
 
538
  *Recommended practice:* Any names that the implementation provides for
539
  the extended floating-point types described in this subsection that are
540
+ in addition to the names declared in the `<stdfloat>` header should be
541
  chosen to increase compatibility and interoperability with the
542
  interchange types `_Float16`, `_Float32`, `_Float64`, and `_Float128`
543
+ defined in ISO/IEC TS 18661-3 and with future versions of \IsoCUndated.
 
544
 
545
  ### Compound types <a id="basic.compound">[[basic.compound]]</a>
546
 
547
  Compound types can be constructed in the following ways:
548
 
549
  - *arrays* of objects of a given type, [[dcl.array]];
550
  - *functions*, which have parameters of given types and return `void` or
551
+ a result of a given type, [[dcl.fct]];
552
  - *pointers* to cv `void` or objects or functions (including static
553
  members of classes) of a given type, [[dcl.ptr]];
554
  - *references* to objects or functions of a given type, [[dcl.ref]].
555
  There are two types of references:
556
  - lvalue reference
557
  - rvalue reference
558
+ - *classes* containing a sequence of class members
559
+ [[class]], [[class.mem]], and a set of restrictions on the access to
 
560
  these entities [[class.access]];
561
  - *unions*, which are classes capable of containing objects of different
562
  types at different times, [[class.union]];
563
  - *enumerations*, which comprise a set of named constant values,
564
  [[dcl.enum]];
565
+ - *pointers to non-static class members*,[^17] which identify members of
566
  a given type within objects of a given class, [[dcl.mptr]]. Pointers
567
  to data members and pointers to member functions are collectively
568
  called *pointer-to-member* types.
569
 
570
  These methods of constructing types can be applied recursively;
 
588
  “pointer to `X`”. — *end example*]
589
 
590
  Except for pointers to static members, text referring to “pointers” does
591
  not apply to pointers to members. Pointers to incomplete types are
592
  allowed although there are restrictions on what can be done with them
593
+ [[basic.types.general]]. Every value of pointer type is one of the
594
+ following:
595
 
596
  - a *pointer to* an object or function (the pointer is said to *point*
597
  to the object or function), or
598
  - a *pointer past the end of* an object [[expr.add]], or
599
  - the *null pointer value* for that type, or
600
  - an *invalid pointer value*.
601
 
602
  A value of a pointer type that is a pointer to or past the end of an
603
  object *represents the address* of the first byte in memory
604
+ [[intro.memory]] occupied by the object[^18]
605
 
606
  or the first byte in memory after the end of the storage occupied by the
607
  object, respectively.
608
 
609
  [*Note 2*: A pointer past the end of an object [[expr.add]] is not
610
  considered to point to an unrelated object of the object’s type, even if
611
+ the unrelated object is located at that address. *end note*]
 
 
612
 
613
  For purposes of pointer arithmetic [[expr.add]] and comparison
614
  [[expr.rel]], [[expr.eq]], a pointer past the end of the last element of
615
  an array `x` of n elements is considered to be equivalent to a pointer
616
+ to a hypothetical array element n of `x`, and an object of type `T` that
617
  is not an array element is considered to belong to an array with one
618
  element of type `T`. The value representation of pointer types is
619
  *implementation-defined*. Pointers to layout-compatible types shall have
620
  the same value representation and alignment requirements
621
  [[basic.align]].
622
 
623
  [*Note 3*: Pointers to over-aligned types [[basic.align]] have no
624
  special representation, but their range of valid values is restricted by
625
  the extended alignment requirement. — *end note*]
626
 
627
+ A pointer value P is *valid in the context of* an evaluation E if P is a
628
+ pointer to function or a null pointer value, or if it is a pointer to or
629
+ past the end of an object O and E happens before the end of the duration
630
+ of the region of storage for O. If a pointer value P is used in an
631
+ evaluation E and P is not valid in the context of E, then the behavior
632
+ is undefined if E is an indirection [[expr.unary.op]] or an invocation
633
+ of a deallocation function [[basic.stc.dynamic.deallocation]], and
634
+ *implementation-defined* otherwise.[^19]
635
+
636
+ [*Note 4*: P can be valid in the context of E even if it points to a
637
+ type unrelated to that of O or if O is not within its lifetime, although
638
+ further restrictions apply to such pointer values
639
+ [[basic.life]], [[basic.lval]], [[expr.add]]. — *end note*]
640
+
641
+ Two objects *a* and *b* are *pointer-interconvertible* if
642
 
643
  - they are the same object, or
644
  - one is a union object and the other is a non-static data member of
645
  that object [[class.union]], or
646
  - one is a standard-layout class object and the other is the first
 
652
 
653
  If two objects are pointer-interconvertible, then they have the same
654
  address, and it is possible to obtain a pointer to one from a pointer to
655
  the other via a `reinterpret_cast` [[expr.reinterpret.cast]].
656
 
657
+ [*Note 5*: An array object and its first element are not
658
  pointer-interconvertible, even though they have the same
659
  address. — *end note*]
660
 
661
  A byte of storage *b* is *reachable through* a pointer value that points
662
  to an object *x* if there is an object *y*, pointer-interconvertible
 
673
  Each type other than a function or reference type is part of a group of
674
  four distinct, but related, types: a *cv-unqualified* version, a
675
  *const-qualified* version, a *volatile-qualified* version, and a
676
  *const-volatile-qualified* version. The types in each such group shall
677
  have the same representation and alignment requirements
678
+ [[basic.align]].[^20]
679
 
680
  A function or reference type is always cv-unqualified.
681
 
682
  - A *const object* is an object of type `const T` or a non-mutable
683
  subobject of a const object.
 
785
  [[expr.arith.conv]]. — *end note*]
786
 
787
  Every floating-point type has a *floating-point conversion rank* defined
788
  as follows:
789
 
790
+ - The rank of a floating-point type `T` is greater than the rank of any
791
  floating-point type whose set of values is a proper subset of the set
792
  of values of `T`.
793
  - The rank of `long double` is greater than the rank of `double`, which
794
  is greater than the rank of `float`.
795
  - Two extended floating-point types with the same set of values have
 
797
  - An extended floating-point type with the same set of values as exactly
798
  one cv-unqualified standard floating-point type has a rank equal to
799
  the rank of that standard floating-point type.
800
  - An extended floating-point type with the same set of values as more
801
  than one cv-unqualified standard floating-point type has a rank equal
802
+ to the rank of `double`.\begin{tailnote}
803
+ The treatment of \texttt{std::float64_t} differs from
804
+ that of the analogous \texttt{\_Float64} in C,
805
+ for example on platforms where all of
806
+ \texttt{\texttt{long} \texttt{double}},
807
+ \texttt{double}, and
808
+ \texttt{std::float64_t}
809
+ have the same set of values (see ISO/IEC 9899:2018 (C)H.4.3).
810
+ \end{tailnote}
811
 
812
  [*Note 2*: The conversion ranks of floating-point types `T1` and `T2`
813
  are unordered if the set of values of `T1` is neither a subset nor a
814
  superset of the set of values of `T2`. This can happen when one type has
815
  both a larger range and a lower precision than the other. — *end note*]