I downloaded Chromium's code base and ran across the WTF namespace.
namespace WTF {
/*
* C++'s idea of a reinterpret_cast lacks sufficient cojones.
*/
template<typename TO, typename FROM>
TO bitwise_cast(FROM in)
{
COMPILE_ASSERT(sizeof(TO) == sizeof(FROM), WTF_wtf_reinterpret_cast_sizeof_types_is_equal);
union {
FROM from;
TO to;
} u;
u.from = in;
return u.to;
}
} // namespace WTF
Does this mean what I think it means? Could be so, the bitwise_cast
implementation specified here will not compile if either TO
or FROM
is not a POD and is not (AFAIK) more powerful than C++ built in reinterpret_cast
.
The only point of light I see here is the nobody seems to be using bitwise_cast
in the Chromium project.