Union Initialization

Rubn where at is.this
Wed Jan 31 03:33:46 UTC 2018


Is there any way to initialize an array of unions with more than 
just the first union type?


struct A { float a; }
struct B { uint b; }

union Test
{
     A a;
     B b;
}

Test[2] test =
[
     Test(A(1.0f)),
     Test(B(10)), // ERROR
];


AFAIK there's no way to specify to use D with an initializer:

Test test = { b: B(10) };


More information about the Digitalmars-d-learn mailing list