Ahh, thanks. Looks like encapsulating the union in a struct with alias this gets the job done, and removes the need for overloads. Neat.

struct vec2 {
        union {
                struct {
                        float x = 0.0f;
                        float y = 0.0f;
                }
                float[2] v;
        }

        this(float x, float y) {
                this.x = x;
                this.y = y;
        }
        this(float[v.length] f) {
                v[0..length] = f[0..length];
        }
        alias v this;
}

Reply via email to