From Jason Turner

[basic.fundamental]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpgpvsp_1m/{from.md → to.md} +135 -100
tmp/tmpgpvsp_1m/{from.md → to.md} RENAMED
@@ -1,134 +1,169 @@
1
  ### Fundamental types <a id="basic.fundamental">[[basic.fundamental]]</a>
2
 
3
- Objects declared as characters (`char`) shall be large enough to store
4
- any member of the implementation’s basic character set. If a character
5
- from this set is stored in a character object, the integral value of
6
- that character object is equal to the value of the single character
7
- literal form of that character. It is *implementation-defined* whether a
8
- `char` object can hold negative values. Characters can be explicitly
9
- declared `unsigned` or `signed`. Plain `char`, `signed char`, and
10
- `unsigned char` are three distinct types, collectively called *narrow
11
- character types*. A `char`, a `signed char`, and an `unsigned char`
12
- occupy the same amount of storage and have the same alignment
13
- requirements ([[basic.align]]); that is, they have the same object
14
- representation. For narrow character types, all bits of the object
15
- representation participate in the value representation.
16
-
17
- [*Note 1*: A bit-field of narrow character type whose length is larger
18
- than the number of bits in the object representation of that type has
19
- padding bits; see  [[class.bit]]. — *end note*]
20
-
21
- For unsigned narrow character types, each possible bit pattern of the
22
- value representation represents a distinct number. These requirements do
23
- not hold for other types. In any particular implementation, a plain
24
- `char` object can take on either the same values as a `signed char` or
25
- an `unsigned
26
- char`; which one is *implementation-defined*. For each value *i* of type
27
- `unsigned char` in the range 0 to 255 inclusive, there exists a value
28
- *j* of type `char` such that the result of an integral conversion (
29
- [[conv.integral]]) from *i* to `char` is *j*, and the result of an
30
- integral conversion from *j* to `unsigned char` is *i*.
31
-
32
  There are five *standard signed integer types* : “`signed char`”,
33
  “`short int`”, “`int`”, “`long int`”, and “`long long int`”. In this
34
  list, each type provides at least as much storage as those preceding it
35
  in the list. There may also be *implementation-defined* *extended signed
36
  integer types*. The standard and extended signed integer types are
37
- collectively called *signed integer types*. Plain `int`s have the
38
- natural size suggested by the architecture of the execution environment
39
- [^22]; the other signed integer types are provided to meet special
40
- needs.
 
 
 
41
 
42
  For each of the standard signed integer types, there exists a
43
  corresponding (but different) *standard unsigned integer type*:
44
  “`unsigned char`”, “`unsigned short int`”, “`unsigned int`”,
45
- “`unsigned long int`”, and “`unsigned long long int`”, each of which
46
- occupies the same amount of storage and has the same alignment
47
- requirements ([[basic.align]]) as the corresponding signed integer
48
- type[^23]; that is, each signed integer type has the same object
49
- representation as its corresponding unsigned integer type. Likewise, for
50
- each of the extended signed integer types there exists a corresponding
51
- *extended unsigned integer type* with the same amount of storage and
52
- alignment requirements. The standard and extended unsigned integer types
53
- are collectively called *unsigned integer types*. The range of
54
- non-negative values of a signed integer type is a subrange of the
55
- corresponding unsigned integer type, the representation of the same
56
- value in each of the two types is the same, and the value representation
57
- of each corresponding signed/unsigned type shall be the same. The
58
- standard signed integer types and standard unsigned integer types are
59
- collectively called the *standard integer types*, and the extended
60
- signed integer types and extended unsigned integer types are
61
- collectively called the *extended integer types*. The signed and
62
- unsigned integer types shall satisfy the constraints given in the C
63
- standard, section 5.2.4.2.1.
64
-
65
- Unsigned integers shall obey the laws of arithmetic modulo 2ⁿ where n is
66
- the number of bits in the value representation of that particular size
67
- of integer.[^24]
68
-
69
- Type `wchar_t` is a distinct type whose values can represent distinct
70
- codes for all members of the largest extended character set specified
71
- among the supported locales ([[locale]]). Type `wchar_t` shall have the
72
- same size, signedness, and alignment requirements ([[basic.align]]) as
73
- one of the other integral types, called its *underlying type*. Types
74
- `char16_t` and `char32_t` denote distinct types with the same size,
75
- signedness, and alignment as `uint_least16_t` and `uint_least32_t`,
76
- respectively, in `<cstdint>`, called the underlying types.
77
-
78
- Values of type `bool` are either `true` or `false`.[^25]
79
-
80
- [*Note 2*: There are no `signed`, `unsigned`, `short`, or `long bool`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  types or values. — *end note*]
82
 
83
- Values of type `bool` participate in integral promotions (
84
- [[conv.prom]]).
 
85
 
86
- Types `bool`, `char`, `char16_t`, `char32_t`, `wchar_t`, and the signed
87
- and unsigned integer types are collectively called *integral*
88
- types.[^26] A synonym for integral type is *integer type*. The
89
- representations of integral types shall define values by use of a pure
90
- binary numeration system.[^27]
91
 
92
- [*Example 1*: This International Standard permits two’s complement,
93
- ones’ complement and signed magnitude representations for integral
94
- types. — *end example*]
95
-
96
- There are three *floating-point* types: `float`, `double`, and
97
  `long double`. The type `double` provides at least as much precision as
98
  `float`, and the type `long double` provides at least as much precision
99
  as `double`. The set of values of the type `float` is a subset of the
100
  set of values of the type `double`; the set of values of the type
101
  `double` is a subset of the set of values of the type `long double`. The
102
  value representation of floating-point types is
103
  *implementation-defined*.
104
 
105
- [*Note 3*: This International Standard imposes no requirements on the
106
- accuracy of floating-point operations; see also 
107
- [[support.limits]]. — *end note*]
108
 
109
- Integral and floating types are collectively called *arithmetic* types.
110
- Specializations of the standard library template `std::numeric_limits` (
111
- [[support.limits]]) shall specify the maximum and minimum values of each
112
- arithmetic type for an implementation.
113
 
114
  A type cv `void` is an incomplete type that cannot be completed; such a
115
  type has an empty set of values. It is used as the return type for
116
  functions that do not return a value. Any expression can be explicitly
117
- converted to type cv `void` ([[expr.cast]]). An expression of type
118
- cv `void` shall be used only as an expression statement (
119
- [[stmt.expr]]), as an operand of a comma expression ([[expr.comma]]),
120
- as a second or third operand of `?:` ([[expr.cond]]), as the operand of
121
- `typeid`, `noexcept`, or `decltype`, as the expression in a return
122
- statement ([[stmt.return]]) for a function with the return type
123
  cv `void`, or as the operand of an explicit conversion to type
124
  cv `void`.
125
 
126
- A value of type `std::nullptr_t` is a null pointer constant (
127
- [[conv.ptr]]). Such values participate in the pointer and the pointer to
128
- member conversions ([[conv.ptr]], [[conv.mem]]).
129
  `sizeof(std::nullptr_t)` shall be equal to `sizeof(void*)`.
130
 
131
- [*Note 4*: Even if the implementation defines two or more basic types
132
- to have the same value representation, they are nevertheless different
133
- types. — *end note*]
 
 
134
 
 
1
  ### Fundamental types <a id="basic.fundamental">[[basic.fundamental]]</a>
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  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
 
16
  For each of the standard signed integer types, there exists a
17
  corresponding (but different) *standard unsigned integer type*:
18
  “`unsigned char`”, “`unsigned short int`”, “`unsigned int`”,
19
+ “`unsigned long int`”, and “`unsigned long long int`”. Likewise, for
20
+ each of the extended signed integer types, there exists a corresponding
21
+ *extended unsigned integer type*. The standard and extended unsigned
22
+ integer types are collectively called *unsigned integer types*. An
23
+ unsigned integer type has the same width *N* as the corresponding signed
24
+ integer type. The range of representable values for the unsigned type is
25
+ 0 to 2ᴺ-1 (inclusive); arithmetic for the unsigned type is performed
26
+ modulo 2ᴺ.
27
+
28
+ [*Note 2*: Unsigned arithmetic does not overflow. Overflow for signed
29
+ arithmetic yields undefined behavior [[expr.pre]]. *end note*]
30
+
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.[^22]
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
+
42
+ **Table: Minimum width** <a id="basic.fundamental.width">[basic.fundamental.width]</a>
43
+
44
+ | Type | Minimum width $N$ |
45
+ | ------------- | ----------------- |
46
+ | `signed char` | 8 |
47
+ | `short` | 16 |
48
+ | `int` | 16 |
49
+ | `long` | 32 |
50
+ | `long long` | 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]] 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
70
+ representation $x = x_0 2^0 + x_1 2^1 + \ldots + x_{N-1} 2^{N-1}$, where
71
+ each coefficient xᵢ is either 0 or 1; this is called the *base-2
72
+ representation* of x. The base-2 representation of a value of signed
73
+ integer type is the base-2 representation of the congruent value of the
74
+ corresponding unsigned integer type. The standard signed integer types
75
+ and standard unsigned integer types are collectively called the
76
+ *standard integer types*, and the extended signed integer types and
77
+ extended unsigned integer types are collectively called the *extended
78
+ integer types*.
79
+
80
+ A fundamental type specified to have a signed or unsigned integer type
81
+ as its *underlying type* has the same object representation, value
82
+ representation, alignment requirements [[basic.align]], and range of
83
+ representable values as the underlying type. Further, each value has the
84
+ same representation in both types.
85
+
86
+ Type `char` is a distinct type that has an *implementation-defined*
87
+ choice of “`signed char`” or “`unsigned char`” as its underlying type.
88
+ The values of type `char` can represent distinct codes for all members
89
+ of the implementation’s basic character set. The three types `char`,
90
+ `signed char`, and `unsigned char` are collectively called *ordinary
91
+ character types*. The ordinary character types and `char8_t` are
92
+ collectively called *narrow character types*. For narrow character
93
+ types, each possible bit pattern of the object representation represents
94
+ a distinct value.
95
+
96
+ [*Note 5*: This requirement does not hold for other
97
+ types. — *end note*]
98
+
99
+ [*Note 6*: A bit-field of narrow character type whose width is larger
100
+ than the width of that type has padding bits; see
101
+ [[basic.types]]. — *end note*]
102
+
103
+ Type `wchar_t` is a distinct type that has an *implementation-defined*
104
+ signed or unsigned integer type as its underlying type. The values of
105
+ type `wchar_t` can represent distinct codes for all members of the
106
+ largest extended character set specified among the supported locales
107
+ [[locale]].
108
+
109
+ Type `char8_t` denotes a distinct type whose underlying type is
110
+ `unsigned char`. Types `char16_t` and `char32_t` denote distinct types
111
+ whose underlying types are `uint_least16_t` and `uint_least32_t`,
112
+ respectively, in `<cstdint>`.
113
+
114
+ Type `bool` is a distinct type that has the same object representation,
115
+ value representation, and alignment requirements as an
116
+ *implementation-defined* unsigned integer type. The values of type
117
+ `bool` are `true` and `false`.
118
+
119
+ [*Note 7*: There are no `signed`, `unsigned`, `short`, or `long bool`
120
  types or values. — *end note*]
121
 
122
+ Types `bool`, `char`, `wchar_t`, `char8_t`, `char16_t`, `char32_t`, and
123
+ the signed and unsigned integer types are collectively called *integral
124
+ types*. A synonym for integral type is *integer type*.
125
 
126
+ [*Note 8*: Enumerations [[dcl.enum]] are not integral; however,
127
+ unscoped enumerations can be promoted to integral types as specified in
128
+ [[conv.prom]]. *end note*]
 
 
129
 
130
+ There are three *floating-point types*: `float`, `double`, and
 
 
 
 
131
  `long double`. The type `double` provides at least as much precision as
132
  `float`, and the type `long double` provides at least as much precision
133
  as `double`. The set of values of the type `float` is a subset of the
134
  set of values of the type `double`; the set of values of the type
135
  `double` is a subset of the set of values of the type `long double`. The
136
  value representation of floating-point types is
137
  *implementation-defined*.
138
 
139
+ [*Note 9*: This document imposes no requirements on the accuracy of
140
+ floating-point operations; see also  [[support.limits]]. — *end note*]
 
141
 
142
+ Integral and floating-point types are collectively called *arithmetic*
143
+ types. Specializations of the standard library template
144
+ `std::numeric_limits` [[support.limits]] shall specify the maximum and
145
+ minimum values of each arithmetic type for an implementation.
146
 
147
  A type cv `void` is an incomplete type that cannot be completed; such a
148
  type has an empty set of values. It is used as the return type for
149
  functions that do not return a value. Any expression can be explicitly
150
+ converted to type cv `void` ([[expr.type.conv]], [[expr.static.cast]],
151
+ [[expr.cast]]). An expression of type cv `void` shall be used only as an
152
+ expression statement [[stmt.expr]], as an operand of a comma expression
153
+ [[expr.comma]], as a second or third operand of `?:` [[expr.cond]], as
154
+ the operand of `typeid`, `noexcept`, or `decltype`, as the expression in
155
+ a `return` statement [[stmt.return]] for a function with the return type
156
  cv `void`, or as the operand of an explicit conversion to type
157
  cv `void`.
158
 
159
+ A value of type `std::nullptr_t` is a null pointer constant
160
+ [[conv.ptr]]. Such values participate in the pointer and the
161
+ pointer-to-member conversions ([[conv.ptr]], [[conv.mem]]).
162
  `sizeof(std::nullptr_t)` shall be equal to `sizeof(void*)`.
163
 
164
+ The types described in this subclause are called *fundamental types*.
165
+
166
+ [*Note 10*: Even if the implementation defines two or more fundamental
167
+ types to have the same value representation, they are nevertheless
168
+ different types. — *end note*]
169