Vector.opCast

Cast to a Vector-like struct.

  1. U opCast()
  2. U opCast()
    struct Vector(T, uint N)
    pure const
    U
    opCast
    (
    U
    )
    ()
    if (
    is(U == struct) &&
    VectorStruct!U.isVectorStruct
    )
    if (
    N > 0
    )

Examples

immutable Vec2 five = 5;
OtherVec2 otherFive = cast(OtherVec2) five;
assert(otherFive == OtherVec2(5, 5));
assert(!__traits(compiles, { auto v = cast(NotAVec2) five; }));

Meta