Vector.opCast

Cast to a static array of same dimension, but different element type.

  1. U opCast()
    struct Vector(T, uint N)
    pure const
    U
    opCast
    (
    U : T2[N]
    T2
    )
    ()
    if (
    N > 0
    )
  2. U opCast()

Examples

Vec2i intVec = [1, 2];
auto floatVec = cast(Vec2) intVec;
assert(floatVec == Vec2(1f, 2f));
assert(floatVec == intVec);

auto floatArray = cast(float[2]) intVec;
assert(floatArray == [1f, 2f]);
assert(floatArray == intVec);

Meta