$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Johan Råde (rade_at_[hidden])
Date: 2006-08-04 06:06:08
And here is an implementation of binary_cast,
based on Gennaro Prota's code.
template<class T, class S>
T binary_cast(const S& s)
{
BOOST_STATIC_ASSERT(sizeof(S) == sizeof(T));
T t;
std::copy(
reinterpret_cast<const volatile char*>(&s),
reinterpret_cast<const volatile char*>(&s) + sizeof(S),
reinterpret_cast<volatile char*>(&t)
);
return t;
}
I still find it hard to believe that the volatile are needed ;-)
But my experience with different compilers is quite limited.
--Johan Råde