Implementing vector swizzle.

TheFlyingFiddle theflyingfiddle at gmail.com
Thu Dec 12 16:53:14 PST 2013


I would like to be able to do this.

auto vector = vec4(1,2,3,4);
vector.zxy += vec3(4,4,4);



I'm currently able to do this:

vector.zxy = vec3(4,4,4);

Assigns 4 to the x,y and z components.

and this

auto other = vector.zxy;
other is a vector3 with
other.x == vector.z
other.y == vector.x
other.z == vector.y

However implementing the
+=, -=, *=, /= operators is tricky.

How would i go about doing that?


More information about the Digitalmars-d-learn mailing list