From Jason Turner

[expr.reinterpret.cast]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp0h4mn3xu/{from.md → to.md} +17 -22
tmp/tmp0h4mn3xu/{from.md → to.md} RENAMED
@@ -45,20 +45,17 @@ prvalue of type “pointer to `T1`” to the type “pointer to `T2`” (where
45
  the original pointer value, the result of such a pointer conversion is
46
  unspecified. see also  [[conv.ptr]] for more details of pointer
47
  conversions.
48
 
49
  An object pointer can be explicitly converted to an object pointer of a
50
- different type.[^13] When a prvalue `v` of type pointer to `T1`” is
51
- converted to the type “pointer to cv `T2`”, the result is
52
- `static_cast<cv T2*>(static_cast<cv void*>(v))` if both `T1` and `T2`
53
- are standard-layout types ([[basic.types]]) and the alignment
54
- requirements of `T2` are no stricter than those of `T1`, or if either
55
- type is `void`. Converting a prvalue of type “pointer to `T1` to the
56
- type pointer to `T2`” (where `T1` and `T2` are object types and where
57
- the alignment requirements of `T2` are no stricter than those of `T1`)
58
- and back to its original type yields the original pointer value. The
59
- result of any other such pointer conversion is unspecified.
60
 
61
  Converting a function pointer to an object pointer type or vice versa is
62
  conditionally-supported. The meaning of such a conversion is
63
  *implementation-defined*, except that if an implementation supports
64
  conversions in both directions, converting a prvalue of one type to the
@@ -72,11 +69,11 @@ pointer constant of integral type is not necessarily converted to a null
72
  pointer value.
73
 
74
  A prvalue of type “pointer to member of `X` of type `T1`” can be
75
  explicitly converted to a prvalue of a different type “pointer to member
76
  of `Y` of type `T2`” if `T1` and `T2` are both function types or both
77
- object types.[^14] The null member pointer value ([[conv.mem]]) is
78
  converted to the null member pointer value of the destination type. The
79
  result of this conversion is unspecified, except in the following cases:
80
 
81
  - converting a prvalue of type “pointer to member function” to a
82
  different pointer to member function type and back to its original
@@ -85,18 +82,16 @@ result of this conversion is unspecified, except in the following cases:
85
  `T1`” to the type “pointer to data member of `Y` of type `T2`” (where
86
  the alignment requirements of `T2` are no stricter than those of `T1`)
87
  and back to its original type yields the original pointer to member
88
  value.
89
 
90
- An lvalue expression of type `T1` can be cast to the type “reference to
91
  `T2`” if an expression of type “pointer to `T1`” can be explicitly
92
- converted to the type “pointer to `T2`” using a `reinterpret_cast`. That
93
- is, a reference cast `reinterpret_cast<T&>(x)` has the same effect as
94
- the conversion `*reinterpret_cast<T*>(&x)` with the built-in `&` and `*`
95
- operators (and similarly for `reinterpret_cast<T&&>(x)`). The result
96
- refers to the same object as the source lvalue, but with a different
97
- type. The result is an lvalue for an lvalue reference type or an rvalue
98
- reference to function type and an xvalue for an rvalue reference to
99
- object type. No temporary is created, no copy is made, and
100
- constructors ([[class.ctor]]) or conversion functions ([[class.conv]])
101
- are not called.[^15]
102
 
 
45
  the original pointer value, the result of such a pointer conversion is
46
  unspecified. see also  [[conv.ptr]] for more details of pointer
47
  conversions.
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 void*>(v))`. Converting a prvalue of
53
+ type “pointer to `T1`” to the type “pointer to `T2`” (where `T1` and
54
+ `T2` are object types and where the alignment requirements of `T2` are
55
+ no stricter than those of `T1`) and back to its original type yields the
56
+ original pointer value.
 
 
 
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
 
69
  pointer value.
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
75
  converted to the null member pointer value of the destination type. The
76
  result of this conversion is unspecified, except in the following cases:
77
 
78
  - converting a prvalue of type “pointer to member function” to a
79
  different pointer to member function type and back to its original
 
82
  `T1`” to the type “pointer to data member of `Y` of type `T2`” (where
83
  the alignment requirements of `T2` are no stricter than those of `T1`)
84
  and back to its original type yields the original pointer to member
85
  value.
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. That is, for lvalues, a reference cast
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)`). No temporary is created, no
95
+ copy is made, and constructors ([[class.ctor]]) or conversion
96
+ functions ([[class.conv]]) are not called.[^14]
 
 
97