vec

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

  1. auto vec(Comps comps)
    pure @safe nothrow @nogc
    vec
    (
    Comps...
    )
    (
    Comps comps
    )
    if (
    Comps.length > 0 &&
    !(
    Comps.length == 1 &&
    isStaticArray!(Comps[0])
    )
    )
  2. auto vec(Arr 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
immutable int[4] arr1 = [1, 2, 4, 0];

static assert( is(Unqual!(typeof(v1)) == DVec4) );

assert(equal(v1.data, arr1[]));

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

Meta