|
Boost : |
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-04-18 19:04:01
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Friday 18 April 2008 17:45 pm, Teemu Torma wrote:
>
> Wouldn't casting using union be safe and efficient in all cases?
> Something like:
>
> inline std::size_t float_hash_impl(float v)
> {
> union { float v; std::size_t seed; } u;
> u.v = v;
> return u.seed;
> }
It's safe with gcc, but that is a gnu extension. The standard only allows
aliasing through char*.
- --
Frank
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFICSjl5vihyNWuA4URAg0BAKDXUcDHivJCccQFhfkG73zW/1jAvACgr7j6
wobgG+feqehkUEnxAhkau7k=
=A3yE
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk