Initialization of unions

Justin Johansson no at spam.com
Thu Sep 23 04:32:54 PDT 2010


One of the problems with C++ is that it is not possible
to create unions with non-primitive members (e.g. structs)
that have constructors.

Surely if you have a struct which essentially implements a tagged
union, one would expect that the union members themselves can
be structs having constructors alongside primitive types, and
that the enclosing struct is empowered to take care of the nested
union member(s) construction and destruction as appropriate.

Is this idiosyncrasy of C++ also apparent in D?

To an extent I am suggesting that unions have better construction
capability.

Trusting that people in the know, know what I'm talking about,
Justin Johansson


More information about the Digitalmars-d mailing list