vec

Build a Vec whose component type and size is deducted from arguments.

  1. auto vec(Comps comps)
  2. auto vec(Arr arr)
    vec
    (
    Arr
    )
    (
    in Arr arr
    )
    if (
    isStaticArray!Arr
    )
  3. template vec(T)
  4. template vec(size_t N)

Examples

import std.algorithm : equal;
import std.traits : Unqual;

immutable v1 = vec (1, 2, 4.0, 0); // CommonType!(int, double) is double

static assert( is(Unqual!(typeof(v1)) == DVec4) );
assert(equal(v1.data, [1, 2, 4, 0]));

immutable int[3] arr = [0, 1, 2];
immutable v2 = vec (arr);
static assert( is(Unqual!(typeof(v2)) == IVec3) );
assert(equal(v2.data, [0, 1, 2]));

Meta