Boost logo

Boost Users :

From: AlisdairM (alisdair.meredith_at_[hidden])
Date: 2006-08-08 14:29:26


John Maddock wrote:

> True. Although there are other benefits that POD'ness brings: union
> support, pass through elipsis etc.

Note that union support and PODness are different issues with a
common-but-distinct set of requirements.

For example ...

struct base { int x; }; // aggregate/POD
struct derived : base {};

derived is neither an aggregate nor a POD, but CAN be stored in a union.
The requirement for a union are nothing to do with aggregates, but
purely concern trivial constructor/destructor/copy-assign operator.

struct agg { derived y; };

agg is an aggregate, is NOT a POD, but can still be stored in a union!.
Similarly for an array of derived.

Likewise, int is a classic POD that is not an aggregate than can be
stored in a union. Most combinations of PODness, aggregate and
union-ability can be achieved with effort.

I have not cross-checked with ellipsis requirements yet to look for
even more perverse combinations, just in case you did not think the
language was confusing enough yet ;¬)

[A very patient group of people at BSI have been waiting for me to
write a paper on this for some time. Main problem is - all I can say
right now is "ain't it awful!", which is not a very productive paper!]

-- 
AlisdairM

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net