There are things that reinterpret_cast
can do that no sequence of static_cast
s can do (all from C++03 5.2.10):
-
A pointer can be explicitly converted to any integral type large enough to hold it.
-
A value of integral type or enumeration type can be explicitly converted to a pointer.
-
A pointer to a function can be explicitly converted to a pointer to a function of a different type.
-
An rvalue of type “pointer to member of
X
of typeT1
” can be explicitly converted to an rvalue of type “pointer to member ofY
of typeT2
” ifT1
andT2
are both function types or both object types.
Also, from C++03 9.2/17:
- A pointer to a POD-struct object, suitably converted using a
reinterpret_cast
, points to its initial member (or if that member is a bit-field, then to the unit in which it resides) and vice versa.