Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2002-10-09 12:11:14

David Abrahams wrote:
> Wow, this seems really difficult to grasp, but I can't understand why.
> 5.2.10 Reinterpret cast
> ...
> 3 The mapping performed by reinterpret_cast is
> implementation-defined. [Note: it might, or might not, produce a
> ^^^^^^^^^^^^^^^^^^^^^^
> representation different from the original value. ]
> That means it does _something_, but only the compiler vendor and those
> who have read the manual know what it does.


would you please stop barking at anyone who dares to use
reinterpret_cast? It's easy to cite the standard and tell them "Don't do
it!", but people don't just use reinterpret_cast to annoy you (Really!
:). Why not help developing a better solution? Maybe static_cast is
better, but it makes the code unreadable and you have to care about too
much details, so it needs to be encapsuled. If boost would provide a
helper function, the actual code might become clearer, as it was the
case for "noncopyable", "next/prior" and other little helpers. They are
all no magic and everyone should be able to live without them, but they
help to make your code shorter and more readable. I suggested a
pointer_cast already, maybe it's even possible to create a
"portable_reinterpret_cast" which does what people expect when using
"reinterpret_cast", but with an implementation you could live with.
Maybe in the long term, reinterpret_cast could even be removed from the
language and the boost-replacement might be called std::reinterpret_cast
by that time - who knows...

Regards, Daniel

Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web:

Boost list run by bdawes at, gregod at, cpdaniel at, john at