Vector.opDispatch

Support swizzling assignment like in shader languages.

  1. auto opDispatch()
  2. void opDispatch(RHS rhs)
    struct Vector(type, int dim)
    nothrow @nogc pure nothrow @nogc pure nothrow @nogc @safe @nogc pure
    void
    opDispatch
    (
    string op
    RHS
    )
    (
    RHS rhs
    )
    if (
    isValidSwizzleOperand!(op, RHS) &&
    is(typeof(Vector!(type, op.length)(rhs)))
    )
    if (
    (dim >= 2) &&
    (dim <= 4)
    )

Examples

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

Meta