Boost logo

Boost :

From: Roland Schwarz (roland.schwarz_at_[hidden])
Date: 2007-10-12 02:41:11

Sebastian Redl wrote:
> Absolutely not. The only circumstance in which you may access a member
> of a union that is not the one that has been most recently set is when
> you access common, structurally conformant members of structs, i.e.

Hmm, you may have missed the details of my example, so I repeat the

struct foo1
   unsigned data[4];

struct foo2
   unsigned data[2];

struct bar
   foo1 a;
   foo2 b;

union { data[6]; bar b; };

Are those types not "layout compatible" as the standard requires for the
access I intend? I mean foo1, foo2 are POD. So the question boils down
to whether foo1 and unsigned data[4] are layout compatible, not?

Roland aka speedsnail

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