From Jason Turner

[expr.reinterpret.cast]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp31h4rdv3/{from.md → to.md} +20 -16
tmp/tmp31h4rdv3/{from.md → to.md} RENAMED
@@ -35,12 +35,12 @@ the conversion has the same meaning and validity as a conversion of
35
  any type to the type `std::nullptr_t`. — *end note*]
36
 
37
  A value of integral type or enumeration type can be explicitly converted
38
  to a pointer. A pointer converted to an integer of sufficient size (if
39
  any such exists on the implementation) and back to the same pointer type
40
- will have its original value; mappings between pointers and integers are
41
- otherwise *implementation-defined*.
42
 
43
  A function pointer can be explicitly converted to a function pointer of
44
  a different type.
45
 
46
  [*Note 4*: The effect of calling a function through a pointer to a
@@ -50,21 +50,18 @@ definition of the function is undefined [[expr.call]]. — *end note*]
50
  Except that converting a prvalue of type “pointer to `T1`” to the type
51
  “pointer to `T2`” (where `T1` and `T2` are function types) and back to
52
  its original type yields the original pointer value, the result of such
53
  a pointer conversion is unspecified.
54
 
55
- [*Note 5*: See also  [[conv.ptr]] for more details of pointer
56
- conversions. — *end note*]
57
-
58
  An object pointer can be explicitly converted to an object pointer of a
59
- different type.[^17]
60
 
61
  When a prvalue `v` of object pointer type is converted to the object
62
  pointer type “pointer to cv `T`”, the result is
63
  `static_cast<cv T*>(static_cast<cv~void*>(v))`.
64
 
65
- [*Note 6*: Converting a pointer of type “pointer to `T1`” that points
66
  to an object of type `T1` to the type “pointer to `T2`” (where `T2` is
67
  an object type and the alignment requirements of `T2` are no stricter
68
  than those of `T1`) and back to its original type yields the original
69
  pointer value. — *end note*]
70
 
@@ -76,19 +73,19 @@ other type and back, possibly with different cv-qualification, shall
76
  yield the original pointer value.
77
 
78
  The null pointer value [[basic.compound]] is converted to the null
79
  pointer value of the destination type.
80
 
81
- [*Note 7*: A null pointer constant of type `std::nullptr_t` cannot be
82
  converted to a pointer type, and a null pointer constant of integral
83
  type is not necessarily converted to a null pointer
84
  value. — *end note*]
85
 
86
  A prvalue of type “pointer to member of `X` of type `T1`” can be
87
  explicitly converted to a prvalue of a different type “pointer to member
88
  of `Y` of type `T2`” if `T1` and `T2` are both function types or both
89
- object types.[^18]
90
 
91
  The null member pointer value [[conv.mem]] is converted to the null
92
  member pointer value of the destination type. The result of this
93
  conversion is unspecified, except in the following cases:
94
 
@@ -99,13 +96,20 @@ conversion is unspecified, except in the following cases:
99
  `T1`” to the type “pointer to data member of `Y` of type `T2`” (where
100
  the alignment requirements of `T2` are no stricter than those of `T1`)
101
  and back to its original type yields the original pointer-to-member
102
  value.
103
 
104
- A glvalue of type `T1`, designating an object *x*, can be cast to the
105
- type “reference to `T2`” if an expression of type “pointer to `T1`” can
106
- be explicitly converted to the type “pointer to `T2`” using a
107
- `reinterpret_cast`. The result is that of `*reinterpret_cast<T2 *>(p)`
108
- where `p` is a pointer to *x* of type “pointer to `T1`”. No temporary is
109
- created, no copy is made, and no constructors [[class.ctor]] or
110
- conversion functions [[class.conv]] are called.[^19]
 
 
 
 
 
 
 
111
 
 
35
  any type to the type `std::nullptr_t`. — *end note*]
36
 
37
  A value of integral type or enumeration type can be explicitly converted
38
  to a pointer. A pointer converted to an integer of sufficient size (if
39
  any such exists on the implementation) and back to the same pointer type
40
+ will have its original value [[basic.compound]]; mappings between
41
+ pointers and integers are otherwise *implementation-defined*.
42
 
43
  A function pointer can be explicitly converted to a function pointer of
44
  a different type.
45
 
46
  [*Note 4*: The effect of calling a function through a pointer to a
 
50
  Except that converting a prvalue of type “pointer to `T1`” to the type
51
  “pointer to `T2`” (where `T1` and `T2` are function types) and back to
52
  its original type yields the original pointer value, the result of such
53
  a pointer conversion is unspecified.
54
 
 
 
 
55
  An object pointer can be explicitly converted to an object pointer of a
56
+ different type.[^15]
57
 
58
  When a prvalue `v` of object pointer type is converted to the object
59
  pointer type “pointer to cv `T`”, the result is
60
  `static_cast<cv T*>(static_cast<cv~void*>(v))`.
61
 
62
+ [*Note 5*: Converting a pointer of type “pointer to `T1`” that points
63
  to an object of type `T1` to the type “pointer to `T2`” (where `T2` is
64
  an object type and the alignment requirements of `T2` are no stricter
65
  than those of `T1`) and back to its original type yields the original
66
  pointer value. — *end note*]
67
 
 
73
  yield the original pointer value.
74
 
75
  The null pointer value [[basic.compound]] is converted to the null
76
  pointer value of the destination type.
77
 
78
+ [*Note 6*: A null pointer constant of type `std::nullptr_t` cannot be
79
  converted to a pointer type, and a null pointer constant of integral
80
  type is not necessarily converted to a null pointer
81
  value. — *end note*]
82
 
83
  A prvalue of type “pointer to member of `X` of type `T1`” can be
84
  explicitly converted to a prvalue of a different type “pointer to member
85
  of `Y` of type `T2`” if `T1` and `T2` are both function types or both
86
+ object types.[^16]
87
 
88
  The null member pointer value [[conv.mem]] is converted to the null
89
  member pointer value of the destination type. The result of this
90
  conversion is unspecified, except in the following cases:
91
 
 
96
  `T1`” to the type “pointer to data member of `Y` of type `T2`” (where
97
  the alignment requirements of `T2` are no stricter than those of `T1`)
98
  and back to its original type yields the original pointer-to-member
99
  value.
100
 
101
+ If `v` is a glvalue of type `T1`, designating an object or function *x*,
102
+ it can be cast to the type “reference to `T2`” if an expression of type
103
+ “pointer to `T1`” can be explicitly converted to the type “pointer to
104
+ `T2`” using a `reinterpret_cast`. The result is that of
105
+ `*reinterpret_cast<T2 *>(p)` where `p` is a pointer to *x* of type
106
+ “pointer to `T1`”.
107
+
108
+ [*Note 7*:
109
+
110
+ No temporary is materialized [[conv.rval]] or created, no copy is made,
111
+ and no constructors [[class.ctor]] or conversion functions
112
+ [[class.conv]] are called.[^17]
113
+
114
+ — *end note*]
115