diff --git a/math.d b/math.d index ce2adad..94aaf9b 100644 --- a/math.d +++ b/math.d @@ -100,12 +100,18 @@ struct Vector(T, int N) } } - ref Vector opAssign(U)(U x) if (is(U: T)) + ref Vector opAssign(U)(U x) if (is(U: T) || isAssignable!(T, U)) { mixin(GenerateLoop!("v[@] = x;", N)()); return this; } + ref Vector opAssign(U)(U u) if (isStaticArray!(U) && U.length == N && isAssignable!(T, typeof(*U.init.ptr))) + { + mixin(GenerateLoop!("v[@] = u[@];", N)()); + return this; + } + ref Vector opAssign(U)(U u) if (is(U : Vector)) { v[] = u.v[]; @@ -1113,4 +1119,10 @@ unittest assert(v3 == v4, "Vec3 CrossN failure"); } */ + + { // Vectors + u32[4] arr = [1, 2, 3, 4]; + Vec4 vec = Vec4(arr); + assert(vec == Vec4(1.0, 2.0, 3.0, 4.0)); + } }