From Jason Turner

[basic.fundamental]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmprq6caj24/{from.md → to.md} +135 -27
tmp/tmprq6caj24/{from.md → to.md} RENAMED
@@ -4,12 +4,12 @@ There are five *standard signed integer types*: “`signed char`”,
4
  “`short int`”, “`int`”, “`long int`”, and “`long long int`”. In this
5
  list, each type provides at least as much storage as those preceding it
6
  in the list. There may also be *implementation-defined* *extended signed
7
  integer types*. The standard and extended signed integer types are
8
  collectively called *signed integer types*. The range of representable
9
- values for a signed integer type is -2ᴺ⁻¹ to 2ᴺ⁻¹-1 (inclusive), where
10
- *N* is called the *width* of the type.
11
 
12
  [*Note 1*: Plain `int`s are intended to have the natural width
13
  suggested by the architecture of the execution environment; the other
14
  signed integer types are provided to meet special needs. — *end note*]
15
 
@@ -31,11 +31,11 @@ arithmetic yields undefined behavior [[expr.pre]]. — *end note*]
31
  An unsigned integer type has the same object representation, value
32
  representation, and alignment requirements [[basic.align]] as the
33
  corresponding signed integer type. For each value x of a signed integer
34
  type, the value of the corresponding unsigned integer type congruent to
35
  x modulo 2ᴺ has the same value of corresponding bits in its value
36
- representation.[^18]
37
 
38
  [*Example 1*: The value -1 of a signed integer type has the same
39
  representation as the largest value of the corresponding unsigned
40
  type. — *end example*]
41
 
@@ -48,22 +48,22 @@ type. — *end example*]
48
  | `int` | 16 |
49
  | `long int` | 32 |
50
  | `long long int` | 64 |
51
 
52
 
53
- The width of each signed integer type shall not be less than the values
54
- specified in [[basic.fundamental.width]]. The value representation of a
55
- signed or unsigned integer type comprises N bits, where N is the
56
- respective width. Each set of values for any padding bits
57
  [[basic.types.general]] in the object representation are alternative
58
  representations of the value specified by the value representation.
59
 
60
  [*Note 3*: Padding bits have unspecified value, but cannot cause traps.
61
- In contrast, see ISO C 6.2.6.2. — *end note*]
62
 
63
  [*Note 4*: The signed and unsigned integer types satisfy the
64
- constraints given in ISO C 5.2.4.2.1. — *end note*]
65
 
66
  Except as specified above, the width of a signed or unsigned integer
67
  type is *implementation-defined*.
68
 
69
  Each value x of an unsigned integer type with width N has a unique
@@ -101,12 +101,12 @@ than the width of that type has padding bits; see
101
  Type `wchar_t` is a distinct type that has an *implementation-defined*
102
  signed or unsigned integer type as its underlying type.
103
 
104
  Type `char8_t` denotes a distinct type whose underlying type is
105
  `unsigned char`. Types `char16_t` and `char32_t` denote distinct types
106
- whose underlying types are `uint_least16_t` and `uint_least32_t`,
107
- respectively, in `<cstdint>`.
108
 
109
  Type `bool` is a distinct type that has the same object representation,
110
  value representation, and alignment requirements as an
111
  *implementation-defined* unsigned integer type. The values of type
112
  `bool` are `true` and `false`.
@@ -146,36 +146,144 @@ interactions with floating-point types. — *end note*]
146
 
147
  Except as specified in [[basic.extended.fp]], the object and value
148
  representations and accuracy of operations of floating-point types are
149
  *implementation-defined*.
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  Integral and floating-point types are collectively termed *arithmetic
152
  types*.
153
 
154
- [*Note 10*: Properties of the arithmetic types, such as their minimum
155
  and maximum representable value, can be queried using the facilities in
156
  the standard library headers `<limits>`, `<climits>`, and
157
  `<cfloat>`. — *end note*]
158
 
159
  A type cv `void` is an incomplete type that cannot be completed; such a
160
  type has an empty set of values. It is used as the return type for
161
- functions that do not return a value. Any expression can be explicitly
162
- converted to type cv `void`
163
- [[expr.type.conv]], [[expr.static.cast]], [[expr.cast]]. An expression
164
- of type cv `void` shall be used only as an expression statement
165
- [[stmt.expr]], as an operand of a comma expression [[expr.comma]], as a
166
- second or third operand of `?:` [[expr.cond]], as the operand of
167
- `typeid`, `noexcept`, or `decltype`, as the expression in a `return`
168
- statement [[stmt.return]] for a function with the return type cv `void`,
169
- or as the operand of an explicit conversion to type cv `void`.
170
-
171
- A value of type `std::nullptr_t` is a null pointer constant
172
- [[conv.ptr]]. Such values participate in the pointer and the
173
- pointer-to-member conversions [[conv.ptr]], [[conv.mem]].
174
- `sizeof(std::nullptr_t)` shall be equal to `sizeof(void*)`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
  The types described in this subclause are called *fundamental types*.
177
 
178
- [*Note 11*: Even if the implementation defines two or more fundamental
179
  types to have the same value representation, they are nevertheless
180
  different types. — *end note*]
181
 
 
4
  “`short int`”, “`int`”, “`long int`”, and “`long long int`”. In this
5
  list, each type provides at least as much storage as those preceding it
6
  in the list. There may also be *implementation-defined* *extended signed
7
  integer types*. The standard and extended signed integer types are
8
  collectively called *signed integer types*. The range of representable
9
+ values for a signed integer type is -2ᴺ⁻¹ to 2ᴺ⁻¹-1 (inclusive), where N
10
+ is called the *width* of the type.
11
 
12
  [*Note 1*: Plain `int`s are intended to have the natural width
13
  suggested by the architecture of the execution environment; the other
14
  signed integer types are provided to meet special needs. — *end note*]
15
 
 
31
  An unsigned integer type has the same object representation, value
32
  representation, and alignment requirements [[basic.align]] as the
33
  corresponding signed integer type. For each value x of a signed integer
34
  type, the value of the corresponding unsigned integer type congruent to
35
  x modulo 2ᴺ has the same value of corresponding bits in its value
36
+ representation.[^16]
37
 
38
  [*Example 1*: The value -1 of a signed integer type has the same
39
  representation as the largest value of the corresponding unsigned
40
  type. — *end example*]
41
 
 
48
  | `int` | 16 |
49
  | `long int` | 32 |
50
  | `long long int` | 64 |
51
 
52
 
53
+ The width of each standard signed integer type shall not be less than
54
+ the values specified in [[basic.fundamental.width]]. The value
55
+ representation of a signed or unsigned integer type comprises N bits,
56
+ where N is the respective width. Each set of values for any padding bits
57
  [[basic.types.general]] in the object representation are alternative
58
  representations of the value specified by the value representation.
59
 
60
  [*Note 3*: Padding bits have unspecified value, but cannot cause traps.
61
+ In contrast, see ISO/IEC 9899:2018 (C) 6.2.6.2. — *end note*]
62
 
63
  [*Note 4*: The signed and unsigned integer types satisfy the
64
+ constraints given in ISO/IEC 9899:2018 (C) 5.3.5.3.2. — *end note*]
65
 
66
  Except as specified above, the width of a signed or unsigned integer
67
  type is *implementation-defined*.
68
 
69
  Each value x of an unsigned integer type with width N has a unique
 
101
  Type `wchar_t` is a distinct type that has an *implementation-defined*
102
  signed or unsigned integer type as its underlying type.
103
 
104
  Type `char8_t` denotes a distinct type whose underlying type is
105
  `unsigned char`. Types `char16_t` and `char32_t` denote distinct types
106
+ whose underlying types are `std::uint_least16_t` and
107
+ `std::uint_least32_t`, respectively, in `<cstdint>`.
108
 
109
  Type `bool` is a distinct type that has the same object representation,
110
  value representation, and alignment requirements as an
111
  *implementation-defined* unsigned integer type. The values of type
112
  `bool` are `true` and `false`.
 
146
 
147
  Except as specified in [[basic.extended.fp]], the object and value
148
  representations and accuracy of operations of floating-point types are
149
  *implementation-defined*.
150
 
151
+ The minimum range of representable values for a floating-point type is
152
+ the most negative finite floating-point number representable in that
153
+ type through the most positive finite floating-point number
154
+ representable in that type. In addition, if negative infinity is
155
+ representable in a type, the range of that type is extended to all
156
+ negative real numbers; likewise, if positive infinity is representable
157
+ in a type, the range of that type is extended to all positive real
158
+ numbers.
159
+
160
+ [*Note 10*: Since negative and positive infinity are representable in
161
+ ISO/IEC 60559 formats, all real numbers lie within the range of
162
+ representable values of a floating-point type adhering to ISO/IEC
163
+ 60559. — *end note*]
164
+
165
  Integral and floating-point types are collectively termed *arithmetic
166
  types*.
167
 
168
+ [*Note 11*: Properties of the arithmetic types, such as their minimum
169
  and maximum representable value, can be queried using the facilities in
170
  the standard library headers `<limits>`, `<climits>`, and
171
  `<cfloat>`. — *end note*]
172
 
173
  A type cv `void` is an incomplete type that cannot be completed; such a
174
  type has an empty set of values. It is used as the return type for
175
+ functions that do not return a value. An expression of type cv `void`
176
+ shall be used only as
177
+
178
+ - an expression statement [[stmt.expr]],
179
+ - the expression in a `return` statement [[stmt.return]] for a function
180
+ with the return type cv `void`,
181
+ - an operand of a comma expression [[expr.comma]],
182
+ - the second or third operand of `?:` [[expr.cond]],
183
+ - the operand of a `typeid` expression [[expr.typeid]],
184
+ - the operand of a `noexcept` operator [[expr.unary.noexcept]],
185
+ - the operand of a `decltype` specifier [[dcl.type.decltype]], or
186
+ - the operand of an explicit conversion to type cv `void`
187
+ [[expr.type.conv]], [[expr.static.cast]], [[expr.cast]].
188
+
189
+ The types denoted by cv `std::nullptr_t` are distinct types. A prvalue
190
+ of type `std::nullptr_t` is a null pointer constant [[conv.ptr]]. Such
191
+ values participate in the pointer and the pointer-to-member conversions
192
+ [[conv.ptr]], [[conv.mem]]. `sizeof(std::nullptr_t)` shall be equal to
193
+ `sizeof(void*)`.
194
+
195
+ A value of type `std::meta::info` is called a *reflection*. There exists
196
+ a unique *null reflection*; every other reflection is a representation
197
+ of
198
+
199
+ - a value of scalar type [[temp.param]],
200
+ - an object with static storage duration [[basic.stc]],
201
+ - a variable [[basic.pre]],
202
+ - a structured binding [[dcl.struct.bind]],
203
+ - a function [[dcl.fct]],
204
+ - a function parameter,
205
+ - an enumerator [[dcl.enum]],
206
+ - an annotation [[dcl.attr.grammar]],
207
+ - a type alias [[dcl.typedef]],
208
+ - a type [[basic.types]],
209
+ - a class member [[class.mem]],
210
+ - an unnamed bit-field [[class.bit]],
211
+ - a class template [[temp.pre]],
212
+ - a function template,
213
+ - a variable template,
214
+ - an alias template [[temp.alias]],
215
+ - a concept [[temp.concept]],
216
+ - a namespace alias [[namespace.alias]],
217
+ - a namespace [[basic.namespace.general]],
218
+ - a direct base class relationship [[class.derived.general]], or
219
+ - a data member description [[class.mem.general]].
220
+
221
+ A reflection is said to *represent* the corresponding construct.
222
+
223
+ [*Note 12*: A reflection of a value can be produced by library
224
+ functions such as `std::meta::constant_of` and
225
+ `std::meta::reflect_constant`. — *end note*]
226
+
227
+ [*Example 2*:
228
+
229
+ ``` cpp
230
+ int arr[] = {1, 2, 3};
231
+ auto [a1, a2, a3] = arr;
232
+ [[=1]] void fn(int n);
233
+ enum Enum { A };
234
+ using Alias = int;
235
+ struct B {};
236
+ struct S : B {
237
+ int mem;
238
+ int : 0;
239
+ };
240
+ template<auto> struct TCls {};
241
+ template<auto> void TFn();
242
+ template<auto> int TVar;
243
+ template<auto N> using TAlias = TCls<N>;
244
+ template<auto> concept Concept = requires { true; };
245
+ namespace NS {};
246
+ namespace NSAlias = NS;
247
+
248
+ constexpr auto ctx = std::meta::access_context::current();
249
+
250
+ constexpr auto r1 = std::meta::reflect_constant(42); // represents int value of 42
251
+ constexpr auto r2 = std::meta::reflect_object(arr[1]); // represents int object
252
+ constexpr auto r3 = ^^arr; // represents a variable
253
+ constexpr auto r4 = ^^a3; // represents a structured binding
254
+ constexpr auto r5 = ^^fn; // represents a function
255
+ constexpr auto r6 = std::meta::parameters_of(^^fn)[0]; // represents a function parameter
256
+ constexpr auto r7 = ^^Enum::A; // represents an enumerator
257
+ constexpr auto r8 = std::meta::annotations_of(^^fn)[0]; // represents an annotation
258
+ constexpr auto r9 = ^^Alias; // represents a type alias
259
+ constexpr auto r10 = ^^S; // represents a type
260
+ constexpr auto r11 = ^^S::mem; // represents a class member
261
+ constexpr auto r12 = std::meta::members_of(^^S, ctx)[1]; // represents an unnamed bit-field
262
+ constexpr auto r13 = ^^TCls; // represents a class template
263
+ constexpr auto r14 = ^^TFn; // represents a function template
264
+ constexpr auto r15 = ^^TVar; // represents a variable template
265
+ constexpr auto r16 = ^^TAlias; // represents an alias template
266
+ constexpr auto r17 = ^^Concept; // represents a concept
267
+ constexpr auto r18 = ^^NSAlias; // represents a namespace alias
268
+ constexpr auto r19 = ^^NS; // represents a namespace
269
+ constexpr auto r20 = std::meta::bases_of(^^S, ctx)[0]; // represents a direct base class relationship
270
+ constexpr auto r21 =
271
+ std::meta::data_member_spec(^^int, {.name="member"}); // represents a data member description
272
+ ```
273
+
274
+ — *end example*]
275
+
276
+ *Recommended practice:* Implementations should not represent other
277
+ constructs specified in this document, such as *using-declarator*s,
278
+ partial template specializations, attributes, placeholder types,
279
+ statements, or expressions, as values of type `std::meta::info`.
280
+
281
+ [*Note 13*: Future revisions of this document can specify semantics for
282
+ reflections representing any such constructs. — *end note*]
283
 
284
  The types described in this subclause are called *fundamental types*.
285
 
286
+ [*Note 14*: Even if the implementation defines two or more fundamental
287
  types to have the same value representation, they are nevertheless
288
  different types. — *end note*]
289