Vector.this

Construct a Vector from another Vector

  1. this(Args args)
  2. this(V vec)
    struct Vector(type, int dim)
    nothrow @nogc pure nothrow @nogc pure nothrow @nogc @safe
    this
    (
    V
    )
    (
    V vec
    )
    if (
    isVector!V &&
    (V.dimension >= dimension)
    )
    if (
    (dim >= 2) &&
    (dim <= 4)
    )
  3. this(valueType value)

Examples

Unittest: Construct a Vector from another Vector

auto v4 = vec4( 1.0f, 2, 3, 4 );
auto v3 = vec3( v4 );
assert( v3 == [ 1, 2, 3 ] );

auto v2 = vec2( v4 );
assert( v2 == [ 1, 2 ] );

/// Different valueTypes
auto v4i = vec4i( 1, 2, 3, 4 );
auto v3d = vec3d( v4i );
assert( v3d == [ 1, 2, 3 ] );

v3d.y = 3.9;
auto v2i = vec2i( v3d );
assert( v2i == [ 1, 3 ] );

Meta