tmp/tmpilr_qldq/{from.md → to.md}
RENAMED
|
@@ -1,108 +1,110 @@
|
|
| 1 |
### Compound types <a id="basic.compound">[[basic.compound]]</a>
|
| 2 |
|
| 3 |
Compound types can be constructed in the following ways:
|
| 4 |
|
| 5 |
-
- *arrays* of objects of a given type,
|
| 6 |
- *functions*, which have parameters of given types and return `void` or
|
| 7 |
-
references or objects of a given type,
|
| 8 |
- *pointers* to cv `void` or objects or functions (including static
|
| 9 |
-
members of classes) of a given type,
|
| 10 |
-
- *references* to objects or functions of a given type,
|
| 11 |
There are two types of references:
|
| 12 |
-
-
|
| 13 |
-
-
|
| 14 |
-
- *classes* containing a sequence of objects of various types
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
[[class.access]]);
|
| 19 |
- *unions*, which are classes capable of containing objects of different
|
| 20 |
-
types at different times,
|
| 21 |
- *enumerations*, which comprise a set of named constant values. Each
|
| 22 |
-
distinct enumeration constitutes a different *enumerated type*,
|
| 23 |
[[dcl.enum]];
|
| 24 |
-
- *pointers to non-static class members*, [^
|
| 25 |
-
of a given type within objects of a given class,
|
|
|
|
|
|
|
| 26 |
|
| 27 |
These methods of constructing types can be applied recursively;
|
| 28 |
-
restrictions are mentioned in [[dcl.
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
The type of a pointer to cv `void` or a pointer to an object type is
|
| 34 |
called an *object pointer type*.
|
| 35 |
|
| 36 |
[*Note 1*: A pointer to `void` does not have a pointer-to-object type,
|
| 37 |
however, because `void` is not an object type. — *end note*]
|
| 38 |
|
| 39 |
The type of a pointer that can designate a function is called a
|
| 40 |
-
*function pointer type*. A pointer to
|
| 41 |
-
as a “pointer to `T`”.
|
| 42 |
|
| 43 |
[*Example 1*: A pointer to an object of type `int` is referred to as
|
| 44 |
“pointer to `int`” and a pointer to an object of class `X` is called a
|
| 45 |
“pointer to `X`”. — *end example*]
|
| 46 |
|
| 47 |
Except for pointers to static members, text referring to “pointers” does
|
| 48 |
not apply to pointers to members. Pointers to incomplete types are
|
| 49 |
-
allowed although there are restrictions on what can be done with them
|
| 50 |
-
[[basic.align]]
|
| 51 |
|
| 52 |
- a *pointer to* an object or function (the pointer is said to *point*
|
| 53 |
to the object or function), or
|
| 54 |
-
- a *pointer past the end of* an object
|
| 55 |
-
- the *null pointer value*
|
| 56 |
- an *invalid pointer value*.
|
| 57 |
|
| 58 |
A value of a pointer type that is a pointer to or past the end of an
|
| 59 |
-
object *represents the address* of the first byte in memory
|
| 60 |
-
[[intro.memory]]
|
| 61 |
memory after the end of the storage occupied by the object,
|
| 62 |
respectively.
|
| 63 |
|
| 64 |
-
[*Note 2*: A pointer past the end of an object
|
| 65 |
considered to point to an unrelated object of the object’s type that
|
| 66 |
might be located at that address. A pointer value becomes invalid when
|
| 67 |
the storage it denotes reaches the end of its storage duration; see
|
| 68 |
[[basic.stc]]. — *end note*]
|
| 69 |
|
| 70 |
-
For purposes of pointer arithmetic
|
| 71 |
[[expr.rel]], [[expr.eq]]), a pointer past the end of the last element
|
| 72 |
of an array `x` of n elements is considered to be equivalent to a
|
| 73 |
-
pointer to a hypothetical element `x
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
[*Note 3*: Pointers to over-aligned types
|
| 79 |
special representation, but their range of valid values is restricted by
|
| 80 |
the extended alignment requirement. — *end note*]
|
| 81 |
|
| 82 |
Two objects *a* and *b* are *pointer-interconvertible* if:
|
| 83 |
|
| 84 |
- they are the same object, or
|
| 85 |
-
- one is a
|
| 86 |
-
|
| 87 |
- one is a standard-layout class object and the other is the first
|
| 88 |
non-static data member of that object, or, if the object has no
|
| 89 |
-
non-static data members,
|
| 90 |
-
|
| 91 |
- there exists an object *c* such that *a* and *c* are
|
| 92 |
pointer-interconvertible, and *c* and *b* are
|
| 93 |
pointer-interconvertible.
|
| 94 |
|
| 95 |
If two objects are pointer-interconvertible, then they have the same
|
| 96 |
address, and it is possible to obtain a pointer to one from a pointer to
|
| 97 |
-
the other via a `reinterpret_cast`
|
| 98 |
|
| 99 |
[*Note 4*: An array object and its first element are not
|
| 100 |
pointer-interconvertible, even though they have the same
|
| 101 |
address. — *end note*]
|
| 102 |
|
| 103 |
-
A pointer to cv
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
cv `char*`.
|
| 108 |
|
|
|
|
| 1 |
### Compound types <a id="basic.compound">[[basic.compound]]</a>
|
| 2 |
|
| 3 |
Compound types can be constructed in the following ways:
|
| 4 |
|
| 5 |
+
- *arrays* of objects of a given type, [[dcl.array]];
|
| 6 |
- *functions*, which have parameters of given types and return `void` or
|
| 7 |
+
references or objects of a given type, [[dcl.fct]];
|
| 8 |
- *pointers* to cv `void` or objects or functions (including static
|
| 9 |
+
members of classes) of a given type, [[dcl.ptr]];
|
| 10 |
+
- *references* to objects or functions of a given type, [[dcl.ref]].
|
| 11 |
There are two types of references:
|
| 12 |
+
- lvalue reference
|
| 13 |
+
- rvalue reference
|
| 14 |
+
- *classes* containing a sequence of objects of various types [[class]],
|
| 15 |
+
a set of types, enumerations and functions for manipulating these
|
| 16 |
+
objects [[class.mfct]], and a set of restrictions on the access to
|
| 17 |
+
these entities [[class.access]];
|
|
|
|
| 18 |
- *unions*, which are classes capable of containing objects of different
|
| 19 |
+
types at different times, [[class.union]];
|
| 20 |
- *enumerations*, which comprise a set of named constant values. Each
|
| 21 |
+
distinct enumeration constitutes a different *enumerated type*,
|
| 22 |
[[dcl.enum]];
|
| 23 |
+
- *pointers to non-static class members*, [^23] which identify members
|
| 24 |
+
of a given type within objects of a given class, [[dcl.mptr]].
|
| 25 |
+
Pointers to data members and pointers to member functions are
|
| 26 |
+
collectively called *pointer-to-member* types.
|
| 27 |
|
| 28 |
These methods of constructing types can be applied recursively;
|
| 29 |
+
restrictions are mentioned in [[dcl.meaning]]. Constructing a type such
|
| 30 |
+
that the number of bytes in its object representation exceeds the
|
| 31 |
+
maximum value representable in the type `std::size_t` [[support.types]]
|
| 32 |
+
is ill-formed.
|
| 33 |
|
| 34 |
The type of a pointer to cv `void` or a pointer to an object type is
|
| 35 |
called an *object pointer type*.
|
| 36 |
|
| 37 |
[*Note 1*: A pointer to `void` does not have a pointer-to-object type,
|
| 38 |
however, because `void` is not an object type. — *end note*]
|
| 39 |
|
| 40 |
The type of a pointer that can designate a function is called a
|
| 41 |
+
*function pointer type*. A pointer to an object of type `T` is referred
|
| 42 |
+
to as a “pointer to `T`”.
|
| 43 |
|
| 44 |
[*Example 1*: A pointer to an object of type `int` is referred to as
|
| 45 |
“pointer to `int`” and a pointer to an object of class `X` is called a
|
| 46 |
“pointer to `X`”. — *end example*]
|
| 47 |
|
| 48 |
Except for pointers to static members, text referring to “pointers” does
|
| 49 |
not apply to pointers to members. Pointers to incomplete types are
|
| 50 |
+
allowed although there are restrictions on what can be done with them
|
| 51 |
+
[[basic.align]]. Every value of pointer type is one of the following:
|
| 52 |
|
| 53 |
- a *pointer to* an object or function (the pointer is said to *point*
|
| 54 |
to the object or function), or
|
| 55 |
+
- a *pointer past the end of* an object [[expr.add]], or
|
| 56 |
+
- the *null pointer value* for that type, or
|
| 57 |
- an *invalid pointer value*.
|
| 58 |
|
| 59 |
A value of a pointer type that is a pointer to or past the end of an
|
| 60 |
+
object *represents the address* of the first byte in memory
|
| 61 |
+
[[intro.memory]] occupied by the object [^24] or the first byte in
|
| 62 |
memory after the end of the storage occupied by the object,
|
| 63 |
respectively.
|
| 64 |
|
| 65 |
+
[*Note 2*: A pointer past the end of an object [[expr.add]] is not
|
| 66 |
considered to point to an unrelated object of the object’s type that
|
| 67 |
might be located at that address. A pointer value becomes invalid when
|
| 68 |
the storage it denotes reaches the end of its storage duration; see
|
| 69 |
[[basic.stc]]. — *end note*]
|
| 70 |
|
| 71 |
+
For purposes of pointer arithmetic [[expr.add]] and comparison (
|
| 72 |
[[expr.rel]], [[expr.eq]]), a pointer past the end of the last element
|
| 73 |
of an array `x` of n elements is considered to be equivalent to a
|
| 74 |
+
pointer to a hypothetical array element n of `x` and an object of type
|
| 75 |
+
`T` that is not an array element is considered to belong to an array
|
| 76 |
+
with one element of type `T`. The value representation of pointer types
|
| 77 |
+
is *implementation-defined*. Pointers to layout-compatible types shall
|
| 78 |
+
have the same value representation and alignment requirements
|
| 79 |
+
[[basic.align]].
|
| 80 |
|
| 81 |
+
[*Note 3*: Pointers to over-aligned types [[basic.align]] have no
|
| 82 |
special representation, but their range of valid values is restricted by
|
| 83 |
the extended alignment requirement. — *end note*]
|
| 84 |
|
| 85 |
Two objects *a* and *b* are *pointer-interconvertible* if:
|
| 86 |
|
| 87 |
- they are the same object, or
|
| 88 |
+
- one is a union object and the other is a non-static data member of
|
| 89 |
+
that object [[class.union]], or
|
| 90 |
- one is a standard-layout class object and the other is the first
|
| 91 |
non-static data member of that object, or, if the object has no
|
| 92 |
+
non-static data members, any base class subobject of that object
|
| 93 |
+
[[class.mem]], or
|
| 94 |
- there exists an object *c* such that *a* and *c* are
|
| 95 |
pointer-interconvertible, and *c* and *b* are
|
| 96 |
pointer-interconvertible.
|
| 97 |
|
| 98 |
If two objects are pointer-interconvertible, then they have the same
|
| 99 |
address, and it is possible to obtain a pointer to one from a pointer to
|
| 100 |
+
the other via a `reinterpret_cast` [[expr.reinterpret.cast]].
|
| 101 |
|
| 102 |
[*Note 4*: An array object and its first element are not
|
| 103 |
pointer-interconvertible, even though they have the same
|
| 104 |
address. — *end note*]
|
| 105 |
|
| 106 |
+
A pointer to cv `void` can be used to point to objects of unknown type.
|
| 107 |
+
Such a pointer shall be able to hold any object pointer. An object of
|
| 108 |
+
type cv `void*` shall have the same representation and alignment
|
| 109 |
+
requirements as cv `char*`.
|
|
|
|
| 110 |
|