alias this and anonymous unions

Danni Coy danni.coy at gmail.com
Mon May 25 01:33:29 UTC 2020


example code:
struct vec3(T)
{
      union
      {
         struct { T x; T y; Tz; }
         T[3] packed;
        }
       alias packed this;
}

void test ()
{
    vec3!int v;
    v = [1,1,1];
}
produces

Deprecation: Cannot use alias this to partially initialize variable

does it make sense to offer this depreciation on a member of a union
which is the same size as the union (IE the largest member)?


More information about the Digitalmars-d mailing list