Vector.opDispatch

Support swizzling assignment like in shader languages.

  1. auto opDispatch [@property getter]
  2. U opDispatch [@property setter]
    struct Vector(T, int N)
    nothrow @nogc @property pure
    void
    opDispatch
    (
    string op
    U
    )
    (
    U x
    )
    if (
    (op.length >= 2) &&
    (isValidSwizzleUnique!op)
    &&
    is(typeof(Vector!(T, op.length)(x)))
    )

Examples

vec3f v = [0, 1, 2];
v.yz = v.zx;
assert(v == [0, 2, 0]);

Meta