tmp/tmp5nspltwe/{from.md → to.md}
RENAMED
|
@@ -2,26 +2,25 @@
|
|
| 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 |
-
|
| 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
|
| 15 |
-
a set of
|
| 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,
|
| 21 |
[[dcl.enum]];
|
| 22 |
-
- *pointers to non-static class members*,[^
|
| 23 |
a given type within objects of a given class, [[dcl.mptr]]. Pointers
|
| 24 |
to data members and pointers to member functions are collectively
|
| 25 |
called *pointer-to-member* types.
|
| 26 |
|
| 27 |
These methods of constructing types can be applied recursively;
|
|
@@ -45,46 +44,59 @@ to as a “pointer to `T`”.
|
|
| 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.
|
|
|
|
| 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 [[expr.add]], or
|
| 55 |
- the *null pointer value* for that type, or
|
| 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]] occupied by the object[^
|
| 61 |
|
| 62 |
or the first byte in memory after the end of the storage occupied by the
|
| 63 |
object, 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, even if
|
| 67 |
-
the unrelated object is located at that address.
|
| 68 |
-
invalid when the storage it denotes reaches the end of its storage
|
| 69 |
-
duration; see [[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 of
|
| 73 |
an array `x` of n elements is considered to be equivalent to a pointer
|
| 74 |
-
to a hypothetical array element n of `x` and an object of type `T` that
|
| 75 |
is not an array element is considered to belong to an array with one
|
| 76 |
element of type `T`. The value representation of pointer types is
|
| 77 |
*implementation-defined*. Pointers to layout-compatible types shall have
|
| 78 |
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
|
@@ -96,11 +108,11 @@ Two objects *a* and *b* are *pointer-interconvertible* if:
|
|
| 96 |
|
| 97 |
If two objects are pointer-interconvertible, then they have the same
|
| 98 |
address, and it is possible to obtain a pointer to one from a pointer to
|
| 99 |
the other via a `reinterpret_cast` [[expr.reinterpret.cast]].
|
| 100 |
|
| 101 |
-
[*Note
|
| 102 |
pointer-interconvertible, even though they have the same
|
| 103 |
address. — *end note*]
|
| 104 |
|
| 105 |
A byte of storage *b* is *reachable through* a pointer value that points
|
| 106 |
to an object *x* if there is an object *y*, pointer-interconvertible
|
|
|
|
| 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 |
+
a result 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 class members
|
| 15 |
+
[[class]], [[class.mem]], and a set of restrictions on the access to
|
|
|
|
| 16 |
these entities [[class.access]];
|
| 17 |
- *unions*, which are classes capable of containing objects of different
|
| 18 |
types at different times, [[class.union]];
|
| 19 |
- *enumerations*, which comprise a set of named constant values,
|
| 20 |
[[dcl.enum]];
|
| 21 |
+
- *pointers to non-static class members*,[^17] which identify members of
|
| 22 |
a given type within objects of a given class, [[dcl.mptr]]. Pointers
|
| 23 |
to data members and pointers to member functions are collectively
|
| 24 |
called *pointer-to-member* types.
|
| 25 |
|
| 26 |
These methods of constructing types can be applied recursively;
|
|
|
|
| 44 |
“pointer to `X`”. — *end example*]
|
| 45 |
|
| 46 |
Except for pointers to static members, text referring to “pointers” does
|
| 47 |
not apply to pointers to members. Pointers to incomplete types are
|
| 48 |
allowed although there are restrictions on what can be done with them
|
| 49 |
+
[[basic.types.general]]. Every value of pointer type is one of the
|
| 50 |
+
following:
|
| 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 [[expr.add]], or
|
| 55 |
- the *null pointer value* for that type, or
|
| 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]] occupied by the object[^18]
|
| 61 |
|
| 62 |
or the first byte in memory after the end of the storage occupied by the
|
| 63 |
object, 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, even if
|
| 67 |
+
the unrelated object is located at that address. — *end note*]
|
|
|
|
|
|
|
| 68 |
|
| 69 |
For purposes of pointer arithmetic [[expr.add]] and comparison
|
| 70 |
[[expr.rel]], [[expr.eq]], a pointer past the end of the last element of
|
| 71 |
an array `x` of n elements is considered to be equivalent to a pointer
|
| 72 |
+
to a hypothetical array element n of `x`, and an object of type `T` that
|
| 73 |
is not an array element is considered to belong to an array with one
|
| 74 |
element of type `T`. The value representation of pointer types is
|
| 75 |
*implementation-defined*. Pointers to layout-compatible types shall have
|
| 76 |
the same value representation and alignment requirements
|
| 77 |
[[basic.align]].
|
| 78 |
|
| 79 |
[*Note 3*: Pointers to over-aligned types [[basic.align]] have no
|
| 80 |
special representation, but their range of valid values is restricted by
|
| 81 |
the extended alignment requirement. — *end note*]
|
| 82 |
|
| 83 |
+
A pointer value P is *valid in the context of* an evaluation E if P is a
|
| 84 |
+
pointer to function or a null pointer value, or if it is a pointer to or
|
| 85 |
+
past the end of an object O and E happens before the end of the duration
|
| 86 |
+
of the region of storage for O. If a pointer value P is used in an
|
| 87 |
+
evaluation E and P is not valid in the context of E, then the behavior
|
| 88 |
+
is undefined if E is an indirection [[expr.unary.op]] or an invocation
|
| 89 |
+
of a deallocation function [[basic.stc.dynamic.deallocation]], and
|
| 90 |
+
*implementation-defined* otherwise.[^19]
|
| 91 |
+
|
| 92 |
+
[*Note 4*: P can be valid in the context of E even if it points to a
|
| 93 |
+
type unrelated to that of O or if O is not within its lifetime, although
|
| 94 |
+
further restrictions apply to such pointer values
|
| 95 |
+
[[basic.life]], [[basic.lval]], [[expr.add]]. — *end note*]
|
| 96 |
+
|
| 97 |
+
Two objects *a* and *b* are *pointer-interconvertible* if
|
| 98 |
|
| 99 |
- they are the same object, or
|
| 100 |
- one is a union object and the other is a non-static data member of
|
| 101 |
that object [[class.union]], or
|
| 102 |
- one is a standard-layout class object and the other is the first
|
|
|
|
| 108 |
|
| 109 |
If two objects are pointer-interconvertible, then they have the same
|
| 110 |
address, and it is possible to obtain a pointer to one from a pointer to
|
| 111 |
the other via a `reinterpret_cast` [[expr.reinterpret.cast]].
|
| 112 |
|
| 113 |
+
[*Note 5*: An array object and its first element are not
|
| 114 |
pointer-interconvertible, even though they have the same
|
| 115 |
address. — *end note*]
|
| 116 |
|
| 117 |
A byte of storage *b* is *reachable through* a pointer value that points
|
| 118 |
to an object *x* if there is an object *y*, pointer-interconvertible
|