tmp/tmpxbbnchrt/{from.md → to.md}
RENAMED
|
@@ -7,11 +7,11 @@ objects ([[intro.object]]), references ([[dcl.ref]]), or functions (
|
|
| 7 |
[[dcl.fct]]).
|
| 8 |
|
| 9 |
For any object (other than a base-class subobject) of trivially copyable
|
| 10 |
type `T`, whether or not the object holds a valid value of type `T`, the
|
| 11 |
underlying bytes ([[intro.memory]]) making up the object can be copied
|
| 12 |
-
into an array of `char` or `unsigned` `char`.[^
|
| 13 |
array of `char` or `unsigned` `char` is copied back into the object, the
|
| 14 |
object shall subsequently hold its original value.
|
| 15 |
|
| 16 |
``` cpp
|
| 17 |
#define N sizeof(T)
|
|
@@ -24,11 +24,11 @@ std::memcpy(&obj, buf, N); // at this point, each subobject of obj of scala
|
|
| 24 |
```
|
| 25 |
|
| 26 |
For any trivially copyable type `T`, if two pointers to `T` point to
|
| 27 |
distinct `T` objects `obj1` and `obj2`, where neither `obj1` nor `obj2`
|
| 28 |
is a base-class subobject, if the underlying bytes ([[intro.memory]])
|
| 29 |
-
making up `obj1` are copied into `obj2`,[^
|
| 30 |
hold the same value as `obj1`.
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
T* t1p;
|
| 34 |
T* t2p;
|
|
@@ -42,28 +42,29 @@ The *object representation* of an object of type `T` is the sequence of
|
|
| 42 |
*N* `unsigned` `char` objects taken up by the object of type `T`, where
|
| 43 |
*N* equals `sizeof(T)`. The *value representation* of an object is the
|
| 44 |
set of bits that hold the value of type `T`. For trivially copyable
|
| 45 |
types, the value representation is a set of bits in the object
|
| 46 |
representation that determines a *value*, which is one discrete element
|
| 47 |
-
of an *implementation-defined* set of values.[^
|
| 48 |
|
| 49 |
-
A class that has been declared but not defined,
|
| 50 |
-
|
| 51 |
-
type
|
| 52 |
-
|
| 53 |
-
to have an
|
|
|
|
| 54 |
|
| 55 |
A class type (such as “`class X`”) might be incomplete at one point in a
|
| 56 |
translation unit and complete later on; the type “`class X`” is the same
|
| 57 |
type at both points. The declared type of an array object might be an
|
| 58 |
array of incomplete class type and therefore incomplete; if the class
|
| 59 |
type is completed later on in the translation unit, the array type
|
| 60 |
becomes complete; the array type at those two points is the same type.
|
| 61 |
The declared type of an array object might be an array of unknown size
|
| 62 |
and therefore be incomplete at one point in a translation unit and
|
| 63 |
complete later on; the array types at those two points (“array of
|
| 64 |
-
unknown bound of `T`” and “array of N `T`”) are different types. The
|
| 65 |
type of a pointer to array of unknown size, or of a type defined by a
|
| 66 |
`typedef` declaration to be an array of unknown size, cannot be
|
| 67 |
completed.
|
| 68 |
|
| 69 |
``` cpp
|
|
@@ -102,37 +103,35 @@ Arithmetic types ([[basic.fundamental]]), enumeration types, pointer
|
|
| 102 |
types, pointer to member types ([[basic.compound]]), `std::nullptr_t`,
|
| 103 |
and cv-qualified versions of these types ([[basic.type.qualifier]]) are
|
| 104 |
collectively called *scalar types*. Scalar types, POD classes (Clause
|
| 105 |
[[class]]), arrays of such types and *cv-qualified* versions of these
|
| 106 |
types ([[basic.type.qualifier]]) are collectively called *POD types*.
|
| 107 |
-
|
| 108 |
-
of such types, and
|
| 109 |
-
[[basic.type.qualifier]]) are collectively
|
| 110 |
-
types*. Scalar types, trivial class types
|
| 111 |
-
such types and cv-qualified versions of
|
| 112 |
-
[[basic.type.qualifier]]) are collectively called *trivial
|
| 113 |
-
Scalar types, standard-layout class types (Clause [[class]]),
|
| 114 |
-
such types and cv-qualified versions of these types (
|
| 115 |
[[basic.type.qualifier]]) are collectively called *standard-layout
|
| 116 |
types*.
|
| 117 |
|
| 118 |
A type is a *literal type* if it is:
|
| 119 |
|
|
|
|
| 120 |
- a scalar type; or
|
| 121 |
-
- a reference type
|
| 122 |
- an array of literal type; or
|
| 123 |
- a class type (Clause [[class]]) that has all of the following
|
| 124 |
properties:
|
| 125 |
- it has a trivial destructor,
|
| 126 |
-
- every constructor call and full-expression in the
|
| 127 |
-
*brace-or-equal-initializer*s for non-static data members (if any)
|
| 128 |
-
is a constant expression ([[expr.const]]),
|
| 129 |
- it is an aggregate type ([[dcl.init.aggr]]) or has at least one
|
| 130 |
`constexpr` constructor or constructor template that is not a copy
|
| 131 |
or move constructor, and
|
| 132 |
-
- all of its non-static data members and base classes are of
|
| 133 |
-
types.
|
| 134 |
|
| 135 |
If two types `T1` and `T2` are the same type, then `T1` and `T2` are
|
| 136 |
*layout-compatible* types. Layout-compatible enumerations are described
|
| 137 |
in [[dcl.enum]]. Layout-compatible standard-layout structs and
|
| 138 |
standard-layout unions are described in [[class.mem]].
|
|
@@ -144,38 +143,43 @@ any member of the implementation’s basic character set. If a character
|
|
| 144 |
from this set is stored in a character object, the integral value of
|
| 145 |
that character object is equal to the value of the single character
|
| 146 |
literal form of that character. It is *implementation-defined* whether a
|
| 147 |
`char` object can hold negative values. Characters can be explicitly
|
| 148 |
declared `unsigned` or `signed`. Plain `char`, `signed char`, and
|
| 149 |
-
`unsigned char` are three distinct types
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
|
|
|
| 153 |
representation participate in the value representation. For unsigned
|
| 154 |
-
character types, all possible bit patterns of the value
|
| 155 |
-
represent numbers. These requirements do not hold for
|
| 156 |
-
any particular implementation, a plain `char` object can
|
| 157 |
-
the same values as a `signed char` or an `unsigned
|
| 158 |
-
char`; which one is *implementation-defined*.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
There are five *standard signed integer types* : “`signed char`”,
|
| 161 |
“`short int`”, “`int`”, “`long int`”, and “`long` `long` `int`”. In this
|
| 162 |
list, each type provides at least as much storage as those preceding it
|
| 163 |
in the list. There may also be *implementation-defined* *extended signed
|
| 164 |
integer types*. The standard and extended signed integer types are
|
| 165 |
collectively called *signed integer types*. Plain `int`s have the
|
| 166 |
natural size suggested by the architecture of the execution
|
| 167 |
-
environment[^
|
| 168 |
special needs.
|
| 169 |
|
| 170 |
For each of the standard signed integer types, there exists a
|
| 171 |
corresponding (but different) *standard unsigned integer type*:
|
| 172 |
“`unsigned char`”, “`unsigned short int`”, “`unsigned int`”,
|
| 173 |
“`unsigned long int`”, and “`unsigned` `long` `long` `int`”, each of
|
| 174 |
which occupies the same amount of storage and has the same alignment
|
| 175 |
requirements ([[basic.align]]) as the corresponding signed integer
|
| 176 |
-
type[^
|
| 177 |
representation as its corresponding unsigned integer type. Likewise, for
|
| 178 |
each of the extended signed integer types there exists a corresponding
|
| 179 |
*extended unsigned integer type* with the same amount of storage and
|
| 180 |
alignment requirements. The standard and extended unsigned integer types
|
| 181 |
are collectively called *unsigned integer types*. The range of
|
|
@@ -183,34 +187,36 @@ non-negative values of a *signed integer* type is a subrange of the
|
|
| 183 |
corresponding *unsigned integer* type, and the value representation of
|
| 184 |
each corresponding signed/unsigned type shall be the same. The standard
|
| 185 |
signed integer types and standard unsigned integer types are
|
| 186 |
collectively called the *standard integer types*, and the extended
|
| 187 |
signed integer types and extended unsigned integer types are
|
| 188 |
-
collectively called the *extended integer types*.
|
|
|
|
|
|
|
| 189 |
|
| 190 |
-
Unsigned integers
|
| 191 |
-
|
| 192 |
-
|
| 193 |
|
| 194 |
Type `wchar_t` is a distinct type whose values can represent distinct
|
| 195 |
codes for all members of the largest extended character set specified
|
| 196 |
among the supported locales ([[locale]]). Type `wchar_t` shall have the
|
| 197 |
same size, signedness, and alignment requirements ([[basic.align]]) as
|
| 198 |
one of the other integral types, called its *underlying type*. Types
|
| 199 |
`char16_t` and `char32_t` denote distinct types with the same size,
|
| 200 |
signedness, and alignment as `uint_least16_t` and `uint_least32_t`,
|
| 201 |
-
respectively, in `<
|
| 202 |
|
| 203 |
-
Values of type `bool` are either `true` or `false`.[^
|
| 204 |
`signed`, `unsigned`, `short`, or `long bool` types or values. Values of
|
| 205 |
type `bool` participate in integral promotions ([[conv.prom]]).
|
| 206 |
|
| 207 |
Types `bool`, `char`, `char16_t`, `char32_t`, `wchar_t`, and the signed
|
| 208 |
and unsigned integer types are collectively called *integral*
|
| 209 |
-
types.[^
|
| 210 |
representations of integral types shall define values by use of a pure
|
| 211 |
-
binary numeration system.[^
|
| 212 |
complement, 1’s complement and signed magnitude representations for
|
| 213 |
integral types.
|
| 214 |
|
| 215 |
There are three *floating point* types: `float`, `double`, and
|
| 216 |
`long double`. The type `double` provides at least as much precision as
|
|
@@ -230,13 +236,13 @@ incomplete type that cannot be completed. It is used as the return type
|
|
| 230 |
for functions that do not return a value. Any expression can be
|
| 231 |
explicitly converted to type *cv* `void` ([[expr.cast]]). An expression
|
| 232 |
of type `void` shall be used only as an expression statement (
|
| 233 |
[[stmt.expr]]), as an operand of a comma expression ([[expr.comma]]),
|
| 234 |
as a second or third operand of `?:` ([[expr.cond]]), as the operand of
|
| 235 |
-
`typeid` or `decltype`, as the expression in a return
|
| 236 |
-
[[stmt.return]]) for a function with the return type `void`,
|
| 237 |
-
operand of an explicit conversion to type cv `void`.
|
| 238 |
|
| 239 |
A value of type `std::nullptr_t` is a null pointer constant (
|
| 240 |
[[conv.ptr]]). Such values participate in the pointer and the pointer to
|
| 241 |
member conversions ([[conv.ptr]], [[conv.mem]]).
|
| 242 |
`sizeof(std::nullptr_t)` shall be equal to `sizeof(void*)`.
|
|
@@ -265,16 +271,18 @@ Compound types can be constructed in the following ways:
|
|
| 265 |
- *unions*, which are classes capable of containing objects of different
|
| 266 |
types at different times, [[class.union]];
|
| 267 |
- *enumerations*, which comprise a set of named constant values. Each
|
| 268 |
distinct enumeration constitutes a different *enumerated type*,
|
| 269 |
[[dcl.enum]];
|
| 270 |
-
- *pointers to non-static* [^
|
| 271 |
of a given type within objects of a given class, [[dcl.mptr]].
|
| 272 |
|
| 273 |
These methods of constructing types can be applied recursively;
|
| 274 |
restrictions are mentioned in [[dcl.ptr]], [[dcl.array]], [[dcl.fct]],
|
| 275 |
-
and [[dcl.ref]].
|
|
|
|
|
|
|
| 276 |
|
| 277 |
The type of a pointer to `void` or a pointer to an object type is called
|
| 278 |
an *object pointer type*. A pointer to `void` does not have a
|
| 279 |
pointer-to-object type, however, because `void` is not an object type.
|
| 280 |
The type of a pointer that can designate a function is called a
|
|
@@ -318,32 +326,33 @@ A type mentioned in [[basic.fundamental]] and [[basic.compound]] is a
|
|
| 318 |
*cv-unqualified type*. Each type which is a cv-unqualified complete or
|
| 319 |
incomplete object type or is `void` ([[basic.types]]) has three
|
| 320 |
corresponding cv-qualified versions of its type: a *const-qualified*
|
| 321 |
version, a *volatile-qualified* version, and a
|
| 322 |
*const-volatile-qualified* version. The term *object type* (
|
| 323 |
-
[[intro.object]]) includes the cv-qualifiers specified
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
object
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
|
| 336 |
A compound type ([[basic.compound]]) is not cv-qualified by the
|
| 337 |
cv-qualifiers (if any) of the types from which it is compounded. Any
|
| 338 |
cv-qualifiers applied to an array type affect the array element type,
|
| 339 |
not the array type ([[dcl.array]]).
|
| 340 |
|
| 341 |
-
Each non-static, non-mutable, non-reference data member of a
|
| 342 |
-
const-qualified class object is const-qualified, each non-static,
|
| 343 |
-
non-reference data member of a volatile-qualified class object is
|
| 344 |
-
volatile-qualified and similarly for members of a const-volatile class.
|
| 345 |
See [[dcl.fct]] and [[class.this]] regarding function types that have
|
| 346 |
*cv-qualifier*s.
|
| 347 |
|
| 348 |
There is a partial ordering on cv-qualifiers, so that a type can be said
|
| 349 |
to be *more cv-qualified* than another. Table
|
|
@@ -365,9 +374,18 @@ In this International Standard, the notation *cv* (or *cv1*, *cv2*,
|
|
| 365 |
etc.), used in the description of types, represents an arbitrary set of
|
| 366 |
cv-qualifiers, i.e., one of {`const`}, {`volatile`}, {`const`,
|
| 367 |
`volatile`}, or the empty set. Cv-qualifiers applied to an array type
|
| 368 |
attach to the underlying element type, so the notation “*cv* `T`,” where
|
| 369 |
`T` is an array type, refers to an array whose elements are
|
| 370 |
-
so-qualified.
|
| 371 |
-
|
| 372 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
|
|
|
|
| 7 |
[[dcl.fct]]).
|
| 8 |
|
| 9 |
For any object (other than a base-class subobject) of trivially copyable
|
| 10 |
type `T`, whether or not the object holds a valid value of type `T`, the
|
| 11 |
underlying bytes ([[intro.memory]]) making up the object can be copied
|
| 12 |
+
into an array of `char` or `unsigned` `char`.[^18] If the content of the
|
| 13 |
array of `char` or `unsigned` `char` is copied back into the object, the
|
| 14 |
object shall subsequently hold its original value.
|
| 15 |
|
| 16 |
``` cpp
|
| 17 |
#define N sizeof(T)
|
|
|
|
| 24 |
```
|
| 25 |
|
| 26 |
For any trivially copyable type `T`, if two pointers to `T` point to
|
| 27 |
distinct `T` objects `obj1` and `obj2`, where neither `obj1` nor `obj2`
|
| 28 |
is a base-class subobject, if the underlying bytes ([[intro.memory]])
|
| 29 |
+
making up `obj1` are copied into `obj2`,[^19] `obj2` shall subsequently
|
| 30 |
hold the same value as `obj1`.
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
T* t1p;
|
| 34 |
T* t2p;
|
|
|
|
| 42 |
*N* `unsigned` `char` objects taken up by the object of type `T`, where
|
| 43 |
*N* equals `sizeof(T)`. The *value representation* of an object is the
|
| 44 |
set of bits that hold the value of type `T`. For trivially copyable
|
| 45 |
types, the value representation is a set of bits in the object
|
| 46 |
representation that determines a *value*, which is one discrete element
|
| 47 |
+
of an *implementation-defined* set of values.[^20]
|
| 48 |
|
| 49 |
+
A class that has been declared but not defined, an enumeration type in
|
| 50 |
+
certain contexts ([[dcl.enum]]), or an array of unknown size or of
|
| 51 |
+
incomplete element type, is an *incompletely-defined object type*.[^21]
|
| 52 |
+
Incompletely-defined object types and the void types are *incomplete
|
| 53 |
+
types* ([[basic.fundamental]]). Objects shall not be defined to have an
|
| 54 |
+
incomplete type.
|
| 55 |
|
| 56 |
A class type (such as “`class X`”) might be incomplete at one point in a
|
| 57 |
translation unit and complete later on; the type “`class X`” is the same
|
| 58 |
type at both points. The declared type of an array object might be an
|
| 59 |
array of incomplete class type and therefore incomplete; if the class
|
| 60 |
type is completed later on in the translation unit, the array type
|
| 61 |
becomes complete; the array type at those two points is the same type.
|
| 62 |
The declared type of an array object might be an array of unknown size
|
| 63 |
and therefore be incomplete at one point in a translation unit and
|
| 64 |
complete later on; the array types at those two points (“array of
|
| 65 |
+
unknown bound of `T`” and “array of `N` `T`”) are different types. The
|
| 66 |
type of a pointer to array of unknown size, or of a type defined by a
|
| 67 |
`typedef` declaration to be an array of unknown size, cannot be
|
| 68 |
completed.
|
| 69 |
|
| 70 |
``` cpp
|
|
|
|
| 103 |
types, pointer to member types ([[basic.compound]]), `std::nullptr_t`,
|
| 104 |
and cv-qualified versions of these types ([[basic.type.qualifier]]) are
|
| 105 |
collectively called *scalar types*. Scalar types, POD classes (Clause
|
| 106 |
[[class]]), arrays of such types and *cv-qualified* versions of these
|
| 107 |
types ([[basic.type.qualifier]]) are collectively called *POD types*.
|
| 108 |
+
Cv-unqualified scalar types, trivially copyable class types (Clause
|
| 109 |
+
[[class]]), arrays of such types, and non-volatile const-qualified
|
| 110 |
+
versions of these types ([[basic.type.qualifier]]) are collectively
|
| 111 |
+
called *trivially copyable types*. Scalar types, trivial class types
|
| 112 |
+
(Clause [[class]]), arrays of such types and cv-qualified versions of
|
| 113 |
+
these types ([[basic.type.qualifier]]) are collectively called *trivial
|
| 114 |
+
types*. Scalar types, standard-layout class types (Clause [[class]]),
|
| 115 |
+
arrays of such types and cv-qualified versions of these types (
|
| 116 |
[[basic.type.qualifier]]) are collectively called *standard-layout
|
| 117 |
types*.
|
| 118 |
|
| 119 |
A type is a *literal type* if it is:
|
| 120 |
|
| 121 |
+
- `void`; or
|
| 122 |
- a scalar type; or
|
| 123 |
+
- a reference type; or
|
| 124 |
- an array of literal type; or
|
| 125 |
- a class type (Clause [[class]]) that has all of the following
|
| 126 |
properties:
|
| 127 |
- it has a trivial destructor,
|
|
|
|
|
|
|
|
|
|
| 128 |
- it is an aggregate type ([[dcl.init.aggr]]) or has at least one
|
| 129 |
`constexpr` constructor or constructor template that is not a copy
|
| 130 |
or move constructor, and
|
| 131 |
+
- all of its non-static data members and base classes are of
|
| 132 |
+
non-volatile literal types.
|
| 133 |
|
| 134 |
If two types `T1` and `T2` are the same type, then `T1` and `T2` are
|
| 135 |
*layout-compatible* types. Layout-compatible enumerations are described
|
| 136 |
in [[dcl.enum]]. Layout-compatible standard-layout structs and
|
| 137 |
standard-layout unions are described in [[class.mem]].
|
|
|
|
| 143 |
from this set is stored in a character object, the integral value of
|
| 144 |
that character object is equal to the value of the single character
|
| 145 |
literal form of that character. It is *implementation-defined* whether a
|
| 146 |
`char` object can hold negative values. Characters can be explicitly
|
| 147 |
declared `unsigned` or `signed`. Plain `char`, `signed char`, and
|
| 148 |
+
`unsigned char` are three distinct types, collectively called *narrow
|
| 149 |
+
character types*. A `char`, a `signed char`, and an `unsigned char`
|
| 150 |
+
occupy the same amount of storage and have the same alignment
|
| 151 |
+
requirements ([[basic.align]]); that is, they have the same object
|
| 152 |
+
representation. For narrow character types, all bits of the object
|
| 153 |
representation participate in the value representation. For unsigned
|
| 154 |
+
narrow character types, all possible bit patterns of the value
|
| 155 |
+
representation represent numbers. These requirements do not hold for
|
| 156 |
+
other types. In any particular implementation, a plain `char` object can
|
| 157 |
+
take on either the same values as a `signed char` or an `unsigned
|
| 158 |
+
char`; which one is *implementation-defined*. For each value *i* of type
|
| 159 |
+
`unsigned char` in the range 0 to 255 inclusive, there exists a value
|
| 160 |
+
*j* of type `char` such that the result of an integral conversion (
|
| 161 |
+
[[conv.integral]]) from *i* to `char` is *j*, and the result of an
|
| 162 |
+
integral conversion from *j* to `unsigned char` is *i*.
|
| 163 |
|
| 164 |
There are five *standard signed integer types* : “`signed char`”,
|
| 165 |
“`short int`”, “`int`”, “`long int`”, and “`long` `long` `int`”. In this
|
| 166 |
list, each type provides at least as much storage as those preceding it
|
| 167 |
in the list. There may also be *implementation-defined* *extended signed
|
| 168 |
integer types*. The standard and extended signed integer types are
|
| 169 |
collectively called *signed integer types*. Plain `int`s have the
|
| 170 |
natural size suggested by the architecture of the execution
|
| 171 |
+
environment[^22]; the other signed integer types are provided to meet
|
| 172 |
special needs.
|
| 173 |
|
| 174 |
For each of the standard signed integer types, there exists a
|
| 175 |
corresponding (but different) *standard unsigned integer type*:
|
| 176 |
“`unsigned char`”, “`unsigned short int`”, “`unsigned int`”,
|
| 177 |
“`unsigned long int`”, and “`unsigned` `long` `long` `int`”, each of
|
| 178 |
which occupies the same amount of storage and has the same alignment
|
| 179 |
requirements ([[basic.align]]) as the corresponding signed integer
|
| 180 |
+
type[^23]; that is, each signed integer type has the same object
|
| 181 |
representation as its corresponding unsigned integer type. Likewise, for
|
| 182 |
each of the extended signed integer types there exists a corresponding
|
| 183 |
*extended unsigned integer type* with the same amount of storage and
|
| 184 |
alignment requirements. The standard and extended unsigned integer types
|
| 185 |
are collectively called *unsigned integer types*. The range of
|
|
|
|
| 187 |
corresponding *unsigned integer* type, and the value representation of
|
| 188 |
each corresponding signed/unsigned type shall be the same. The standard
|
| 189 |
signed integer types and standard unsigned integer types are
|
| 190 |
collectively called the *standard integer types*, and the extended
|
| 191 |
signed integer types and extended unsigned integer types are
|
| 192 |
+
collectively called the *extended integer types*. The signed and
|
| 193 |
+
unsigned integer types shall satisfy the constraints given in the C
|
| 194 |
+
standard, section 5.2.4.2.1.
|
| 195 |
|
| 196 |
+
Unsigned integers shall obey the laws of arithmetic modulo 2ⁿ where n is
|
| 197 |
+
the number of bits in the value representation of that particular size
|
| 198 |
+
of integer.[^24]
|
| 199 |
|
| 200 |
Type `wchar_t` is a distinct type whose values can represent distinct
|
| 201 |
codes for all members of the largest extended character set specified
|
| 202 |
among the supported locales ([[locale]]). Type `wchar_t` shall have the
|
| 203 |
same size, signedness, and alignment requirements ([[basic.align]]) as
|
| 204 |
one of the other integral types, called its *underlying type*. Types
|
| 205 |
`char16_t` and `char32_t` denote distinct types with the same size,
|
| 206 |
signedness, and alignment as `uint_least16_t` and `uint_least32_t`,
|
| 207 |
+
respectively, in `<cstdint>`, called the underlying types.
|
| 208 |
|
| 209 |
+
Values of type `bool` are either `true` or `false`.[^25] There are no
|
| 210 |
`signed`, `unsigned`, `short`, or `long bool` types or values. Values of
|
| 211 |
type `bool` participate in integral promotions ([[conv.prom]]).
|
| 212 |
|
| 213 |
Types `bool`, `char`, `char16_t`, `char32_t`, `wchar_t`, and the signed
|
| 214 |
and unsigned integer types are collectively called *integral*
|
| 215 |
+
types.[^26] A synonym for integral type is *integer type*. The
|
| 216 |
representations of integral types shall define values by use of a pure
|
| 217 |
+
binary numeration system.[^27] this International Standard permits 2’s
|
| 218 |
complement, 1’s complement and signed magnitude representations for
|
| 219 |
integral types.
|
| 220 |
|
| 221 |
There are three *floating point* types: `float`, `double`, and
|
| 222 |
`long double`. The type `double` provides at least as much precision as
|
|
|
|
| 236 |
for functions that do not return a value. Any expression can be
|
| 237 |
explicitly converted to type *cv* `void` ([[expr.cast]]). An expression
|
| 238 |
of type `void` shall be used only as an expression statement (
|
| 239 |
[[stmt.expr]]), as an operand of a comma expression ([[expr.comma]]),
|
| 240 |
as a second or third operand of `?:` ([[expr.cond]]), as the operand of
|
| 241 |
+
`typeid`, `noexcept`, or `decltype`, as the expression in a return
|
| 242 |
+
statement ([[stmt.return]]) for a function with the return type `void`,
|
| 243 |
+
or as the operand of an explicit conversion to type cv `void`.
|
| 244 |
|
| 245 |
A value of type `std::nullptr_t` is a null pointer constant (
|
| 246 |
[[conv.ptr]]). Such values participate in the pointer and the pointer to
|
| 247 |
member conversions ([[conv.ptr]], [[conv.mem]]).
|
| 248 |
`sizeof(std::nullptr_t)` shall be equal to `sizeof(void*)`.
|
|
|
|
| 271 |
- *unions*, which are classes capable of containing objects of different
|
| 272 |
types at different times, [[class.union]];
|
| 273 |
- *enumerations*, which comprise a set of named constant values. Each
|
| 274 |
distinct enumeration constitutes a different *enumerated type*,
|
| 275 |
[[dcl.enum]];
|
| 276 |
+
- *pointers to non-static* [^28] *class members*, which identify members
|
| 277 |
of a given type within objects of a given class, [[dcl.mptr]].
|
| 278 |
|
| 279 |
These methods of constructing types can be applied recursively;
|
| 280 |
restrictions are mentioned in [[dcl.ptr]], [[dcl.array]], [[dcl.fct]],
|
| 281 |
+
and [[dcl.ref]]. Constructing a type such that the number of bytes in
|
| 282 |
+
its object representation exceeds the maximum value representable in the
|
| 283 |
+
type `std::size_t` ([[support.types]]) is ill-formed.
|
| 284 |
|
| 285 |
The type of a pointer to `void` or a pointer to an object type is called
|
| 286 |
an *object pointer type*. A pointer to `void` does not have a
|
| 287 |
pointer-to-object type, however, because `void` is not an object type.
|
| 288 |
The type of a pointer that can designate a function is called a
|
|
|
|
| 326 |
*cv-unqualified type*. Each type which is a cv-unqualified complete or
|
| 327 |
incomplete object type or is `void` ([[basic.types]]) has three
|
| 328 |
corresponding cv-qualified versions of its type: a *const-qualified*
|
| 329 |
version, a *volatile-qualified* version, and a
|
| 330 |
*const-volatile-qualified* version. The term *object type* (
|
| 331 |
+
[[intro.object]]) includes the cv-qualifiers specified in the
|
| 332 |
+
*decl-specifier-seq* ([[dcl.spec]]), *declarator* (Clause
|
| 333 |
+
[[dcl.decl]]), *type-id* ([[dcl.name]]), or *new-type-id* (
|
| 334 |
+
[[expr.new]]) when the object is created.
|
| 335 |
+
|
| 336 |
+
- A *const object* is an object of type `const T` or a non-mutable
|
| 337 |
+
subobject of such an object.
|
| 338 |
+
- A *volatile object* is an object of type `volatile T`, a subobject of
|
| 339 |
+
such an object, or a mutable subobject of a const volatile object.
|
| 340 |
+
- A *const volatile object* is an object of type `const volatile T`, a
|
| 341 |
+
non-mutable subobject of such an object, a const subobject of a
|
| 342 |
+
volatile object, or a non-mutable volatile subobject of a const
|
| 343 |
+
object.
|
| 344 |
+
|
| 345 |
+
The cv-qualified or cv-unqualified versions of a type are distinct
|
| 346 |
+
types; however, they shall have the same representation and alignment
|
| 347 |
+
requirements ([[basic.align]]).[^29]
|
| 348 |
|
| 349 |
A compound type ([[basic.compound]]) is not cv-qualified by the
|
| 350 |
cv-qualifiers (if any) of the types from which it is compounded. Any
|
| 351 |
cv-qualifiers applied to an array type affect the array element type,
|
| 352 |
not the array type ([[dcl.array]]).
|
| 353 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
See [[dcl.fct]] and [[class.this]] regarding function types that have
|
| 355 |
*cv-qualifier*s.
|
| 356 |
|
| 357 |
There is a partial ordering on cv-qualifiers, so that a type can be said
|
| 358 |
to be *more cv-qualified* than another. Table
|
|
|
|
| 374 |
etc.), used in the description of types, represents an arbitrary set of
|
| 375 |
cv-qualifiers, i.e., one of {`const`}, {`volatile`}, {`const`,
|
| 376 |
`volatile`}, or the empty set. Cv-qualifiers applied to an array type
|
| 377 |
attach to the underlying element type, so the notation “*cv* `T`,” where
|
| 378 |
`T` is an array type, refers to an array whose elements are
|
| 379 |
+
so-qualified. An array type whose elements are cv-qualified is also
|
| 380 |
+
considered to have the same cv-qualifications as its elements.
|
| 381 |
+
|
| 382 |
+
``` cpp
|
| 383 |
+
typedef char CA[5];
|
| 384 |
+
typedef const char CC;
|
| 385 |
+
CC arr1[5] = { 0 };
|
| 386 |
+
const CA arr2 = { 0 };
|
| 387 |
+
```
|
| 388 |
+
|
| 389 |
+
The type of both `arr1` and `arr2` is “array of 5 `const char`,” and the
|
| 390 |
+
array type is considered to be `const`-qualified.
|
| 391 |
|