The reinterpret_cast
as we know can cast any pointer type to any another pointer type. The question I want to ask regarding this cast operator are:
- How does
reinterpret_cast
work, What is the magic(the internal implementation) that allows reinterpret_cast to work? - How to ensure safety when using
reinterpret_cast
? As far as i know, it doesn't guarantee of safe casting, So what precaution to take while usingreinterpret_cast?
- What is the practical usage of this operator. I have not really encountered it in my professional programing experience, wherein I could'nt get around without using this operator.Any practical examples apart from usual int* to char* will be highly helpful and appreciated.
One other Question regarding casting operators in general:
Casting operators(static_cast
, dynamic_cast
, const_cast
, reinterpret_cast
) are all called Operators
i.e is to the best of my understanding, So is it correct statement to make that casting operators cannot be overloaded unlike most other operators
(I am aware not all operators can be overloaded and I am aware of which can't be(except the Q I am asking, Please refrain flaming me on that) Just I had this doubt that since they are operators, what does the standard say about these?