Vector.this

Construct a Vector from another Vector

  1. this(Args args)
  2. this(V vec)
    struct Vector(type, int dim)
    @safe pure nothrow
    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

1 auto v4 = vec4( 1.0f, 2, 3, 4 );
2 auto v3 = vec3( v4 );
3 assert( v3 == [ 1, 2, 3 ] );
4 
5 auto v2 = vec2( v4 );
6 assert( v2 == [ 1, 2 ] );
7 
8 /// Different valueTypes
9 auto v4i = vec4i( 1, 2, 3, 4 );
10 auto v3d = vec3d( v4i );
11 assert( v3d == [ 1, 2, 3 ] );
12 
13 v3d.y = 3.9;
14 auto v2i = vec2i( v3d );
15 assert( v2i == [ 1, 3 ] );

Meta