detect anonymous union at compile time

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Mar 28 19:24:48 PDT 2013


On 3/28/13, cal <callumenator at gmail.com> wrote:
> Just realized that format.d is able to figure it out, since it
> prints #{overlap...} for unions. I can use that code, which works
> regardless of protection. Thanks

Ah, I didn't even know .tupleof would contain .offsetof.

void main()
{
    static if (S.tupleof[0].offsetof == S.tupleof[1].offsetof)
        pragma(msg, "Union");
}


More information about the Digitalmars-d-learn mailing list