Boost logo

Boost :

From: Matt Doyle (mdoyle_at_[hidden])
Date: 2008-04-18 18:52:42

> [mailto:boost-bounces_at_[hidden]] On Behalf Of Roland Schwarz
> Teemu Torma wrote:
> > Wouldn't casting using union be safe and efficient in all cases?
> I don't know anything about the specific problem at hand, but
> this hopefully is in carefully controlled code, i.e. platform
> dependant and the like. AFAIK this usage is not std c++.
> (But I might be wrong.)
No I think your right. Reading a member of a union other than the last
one written to is undefined behavior. See #97 in Sutter-2005 or #C.8.2
in Stroustrup-2000, they both advise strongly against trying this.

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