tmp/tmpt0panxzx/{from.md → to.md}
RENAMED
|
@@ -14,61 +14,77 @@ performed explicitly using `reinterpret_cast`.
|
|
| 14 |
The `reinterpret_cast` operator shall not cast away constness (
|
| 15 |
[[expr.const.cast]]). An expression of integral, enumeration, pointer,
|
| 16 |
or pointer-to-member type can be explicitly converted to its own type;
|
| 17 |
such a cast yields the value of its operand.
|
| 18 |
|
| 19 |
-
The mapping performed by `reinterpret_cast` might, or might
|
| 20 |
-
a representation different from the original
|
|
|
|
| 21 |
|
| 22 |
A pointer can be explicitly converted to any integral type large enough
|
| 23 |
-
to hold it. The mapping function is implementation-defined.
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
`
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
A value of integral type or enumeration type can be explicitly converted
|
| 32 |
to a pointer. A pointer converted to an integer of sufficient size (if
|
| 33 |
any such exists on the implementation) and back to the same pointer type
|
| 34 |
will have its original value; mappings between pointers and integers are
|
| 35 |
-
otherwise *implementation-defined*.
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
A function pointer can be explicitly converted to a function pointer of
|
| 40 |
-
a different type.
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
An object pointer can be explicitly converted to an object pointer of a
|
| 50 |
different type.[^12] When a prvalue `v` of object pointer type is
|
| 51 |
converted to the object pointer type “pointer to cv `T`”, the result is
|
| 52 |
-
`static_cast<cv T*>(static_cast<cv
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
|
| 58 |
Converting a function pointer to an object pointer type or vice versa is
|
| 59 |
conditionally-supported. The meaning of such a conversion is
|
| 60 |
*implementation-defined*, except that if an implementation supports
|
| 61 |
conversions in both directions, converting a prvalue of one type to the
|
| 62 |
other type and back, possibly with different cv-qualification, shall
|
| 63 |
yield the original pointer value.
|
| 64 |
|
| 65 |
The null pointer value ([[conv.ptr]]) is converted to the null pointer
|
| 66 |
-
value of the destination type.
|
| 67 |
-
|
| 68 |
-
pointer constant of
|
| 69 |
-
pointer
|
|
|
|
|
|
|
| 70 |
|
| 71 |
A prvalue of type “pointer to member of `X` of type `T1`” can be
|
| 72 |
explicitly converted to a prvalue of a different type “pointer to member
|
| 73 |
of `Y` of type `T2`” if `T1` and `T2` are both function types or both
|
| 74 |
object types.[^13] The null member pointer value ([[conv.mem]]) is
|
|
@@ -86,12 +102,16 @@ result of this conversion is unspecified, except in the following cases:
|
|
| 86 |
|
| 87 |
A glvalue expression of type `T1` can be cast to the type “reference to
|
| 88 |
`T2`” if an expression of type “pointer to `T1`” can be explicitly
|
| 89 |
converted to the type “pointer to `T2`” using a `reinterpret_cast`. The
|
| 90 |
result refers to the same object as the source glvalue, but with the
|
| 91 |
-
specified type.
|
|
|
|
|
|
|
| 92 |
`reinterpret_cast<T&>(x)` has the same effect as the conversion
|
| 93 |
`*reinterpret_cast<T*>(&x)` with the built-in `&` and `*` operators (and
|
| 94 |
-
similarly for `reinterpret_cast<T&&>(x)`).
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
| 97 |
|
|
|
|
| 14 |
The `reinterpret_cast` operator shall not cast away constness (
|
| 15 |
[[expr.const.cast]]). An expression of integral, enumeration, pointer,
|
| 16 |
or pointer-to-member type can be explicitly converted to its own type;
|
| 17 |
such a cast yields the value of its operand.
|
| 18 |
|
| 19 |
+
[*Note 1*: The mapping performed by `reinterpret_cast` might, or might
|
| 20 |
+
not, produce a representation different from the original
|
| 21 |
+
value. — *end note*]
|
| 22 |
|
| 23 |
A pointer can be explicitly converted to any integral type large enough
|
| 24 |
+
to hold it. The mapping function is *implementation-defined*.
|
| 25 |
+
|
| 26 |
+
[*Note 2*: It is intended to be unsurprising to those who know the
|
| 27 |
+
addressing structure of the underlying machine. — *end note*]
|
| 28 |
+
|
| 29 |
+
A value of type `std::nullptr_t` can be converted to an integral type;
|
| 30 |
+
the conversion has the same meaning and validity as a conversion of
|
| 31 |
+
`(void*)0` to the integral type.
|
| 32 |
+
|
| 33 |
+
[*Note 3*: A `reinterpret_cast` cannot be used to convert a value of
|
| 34 |
+
any type to the type `std::nullptr_t`. — *end note*]
|
| 35 |
|
| 36 |
A value of integral type or enumeration type can be explicitly converted
|
| 37 |
to a pointer. A pointer converted to an integer of sufficient size (if
|
| 38 |
any such exists on the implementation) and back to the same pointer type
|
| 39 |
will have its original value; mappings between pointers and integers are
|
| 40 |
+
otherwise *implementation-defined*.
|
| 41 |
+
|
| 42 |
+
[*Note 4*: Except as described in [[basic.stc.dynamic.safety]], the
|
| 43 |
+
result of such a conversion will not be a safely-derived pointer
|
| 44 |
+
value. — *end note*]
|
| 45 |
|
| 46 |
A function pointer can be explicitly converted to a function pointer of
|
| 47 |
+
a different type.
|
| 48 |
+
|
| 49 |
+
[*Note 5*: The effect of calling a function through a pointer to a
|
| 50 |
+
function type ([[dcl.fct]]) that is not the same as the type used in
|
| 51 |
+
the definition of the function is undefined. — *end note*]
|
| 52 |
+
|
| 53 |
+
Except that converting a prvalue of type “pointer to `T1`” to the type
|
| 54 |
+
“pointer to `T2`” (where `T1` and `T2` are function types) and back to
|
| 55 |
+
its original type yields the original pointer value, the result of such
|
| 56 |
+
a pointer conversion is unspecified.
|
| 57 |
+
|
| 58 |
+
[*Note 6*: See also [[conv.ptr]] for more details of pointer
|
| 59 |
+
conversions. — *end note*]
|
| 60 |
|
| 61 |
An object pointer can be explicitly converted to an object pointer of a
|
| 62 |
different type.[^12] When a prvalue `v` of object pointer type is
|
| 63 |
converted to the object pointer type “pointer to cv `T`”, the result is
|
| 64 |
+
`static_cast<cv T*>(static_cast<cv~void*>(v))`.
|
| 65 |
+
|
| 66 |
+
[*Note 7*: Converting a prvalue of type “pointer to `T1`” to the type
|
| 67 |
+
“pointer to `T2`” (where `T1` and `T2` are object types and where the
|
| 68 |
+
alignment requirements of `T2` are no stricter than those of `T1`) and
|
| 69 |
+
back to its original type yields the original pointer
|
| 70 |
+
value. — *end note*]
|
| 71 |
|
| 72 |
Converting a function pointer to an object pointer type or vice versa is
|
| 73 |
conditionally-supported. The meaning of such a conversion is
|
| 74 |
*implementation-defined*, except that if an implementation supports
|
| 75 |
conversions in both directions, converting a prvalue of one type to the
|
| 76 |
other type and back, possibly with different cv-qualification, shall
|
| 77 |
yield the original pointer value.
|
| 78 |
|
| 79 |
The null pointer value ([[conv.ptr]]) is converted to the null pointer
|
| 80 |
+
value of the destination type.
|
| 81 |
+
|
| 82 |
+
[*Note 8*: A null pointer constant of type `std::nullptr_t` cannot be
|
| 83 |
+
converted to a pointer type, and a null pointer constant of integral
|
| 84 |
+
type is not necessarily converted to a null pointer
|
| 85 |
+
value. — *end note*]
|
| 86 |
|
| 87 |
A prvalue of type “pointer to member of `X` of type `T1`” can be
|
| 88 |
explicitly converted to a prvalue of a different type “pointer to member
|
| 89 |
of `Y` of type `T2`” if `T1` and `T2` are both function types or both
|
| 90 |
object types.[^13] The null member pointer value ([[conv.mem]]) is
|
|
|
|
| 102 |
|
| 103 |
A glvalue expression of type `T1` can be cast to the type “reference to
|
| 104 |
`T2`” if an expression of type “pointer to `T1`” can be explicitly
|
| 105 |
converted to the type “pointer to `T2`” using a `reinterpret_cast`. The
|
| 106 |
result refers to the same object as the source glvalue, but with the
|
| 107 |
+
specified type.
|
| 108 |
+
|
| 109 |
+
[*Note 9*: That is, for lvalues, a reference cast
|
| 110 |
`reinterpret_cast<T&>(x)` has the same effect as the conversion
|
| 111 |
`*reinterpret_cast<T*>(&x)` with the built-in `&` and `*` operators (and
|
| 112 |
+
similarly for `reinterpret_cast<T&&>(x)`). — *end note*]
|
| 113 |
+
|
| 114 |
+
No temporary is created, no copy is made, and constructors (
|
| 115 |
+
[[class.ctor]]) or conversion functions ([[class.conv]]) are not
|
| 116 |
+
called.[^14]
|
| 117 |
|