diff --git a/include/blt/math/vectors.h b/include/blt/math/vectors.h index 62d5206..5904102 100644 --- a/include/blt/math/vectors.h +++ b/include/blt/math/vectors.h @@ -39,12 +39,14 @@ namespace blt { elements[i] = *(args.begin() + i); } - explicit vec(const T elem[size]) { - for (uint32_t i = 0; i < size; i++) + explicit vec(const T elem[], uint32_t v_size) { + for (uint32_t i = 0; i < v_size; i++) elements[i] = elem[i]; } - vec(const vec& copy): vec(copy.elements) {} + vec(const vec& copy): vec(copy.elements, size) {} + template + vec(const vec<_T, _size>& copy): vec(copy.elements, size) {} vec& operator=(const vec& copy) { if (© == this) @@ -175,82 +177,82 @@ namespace blt { template inline constexpr vec operator+(const vec& left, const vec& right) { - T initializer[size]; + vec initializer{}; for (uint32_t i = 0; i < size; i++) initializer[i] = left[i] + right[i]; - return vec{initializer}; + return initializer; } template inline constexpr vec operator-(const vec& left, const vec& right) { - T initializer[size]; + vec initializer{}; for (uint32_t i = 0; i < size; i++) initializer[i] = left[i] - right[i]; - return vec{initializer}; + return initializer; } template inline constexpr vec operator+(const vec& left, T f) { - T initializer[size]; + vec initializer{}; for (uint32_t i = 0; i < size; i++) initializer[i] = left[i] + f; - return vec{initializer}; + return initializer; } template inline constexpr vec operator-(const vec& left, T f) { - T initializer[size]; + vec initializer{}; for (uint32_t i = 0; i < size; i++) initializer[i] = left[i] + f; - return vec{initializer}; + return initializer; } template inline constexpr vec operator+(T f, const vec& right) { - T initializer[size]; + vec initializer{}; for (uint32_t i = 0; i < size; i++) initializer[i] = f + right[i]; - return vec{initializer}; + return initializer; } template inline constexpr vec operator-(T f, const vec& right) { - T initializer[size]; + vec initializer{}; for (uint32_t i = 0; i < size; i++) initializer[i] = f - right[i]; - return vec{initializer}; + return initializer; } template inline constexpr vec operator*(const vec& left, const vec& right) { - T initializer[size]; + vec initializer{}; for (uint32_t i = 0; i < size; i++) initializer[i] = left[i] * right[i]; - return vec{initializer}; + return initializer; } template inline constexpr vec operator*(const vec& left, T f) { - T initializer[size]; + vec initializer{}; for (uint32_t i = 0; i < size; i++) initializer[i] = left[i] * f; - return vec{initializer}; + return initializer; } template inline constexpr vec operator*(T f, const vec& right) { - T initializer[size]; + vec initializer{}; for (uint32_t i = 0; i < size; i++) initializer[i] = f * right[i]; - return vec{initializer}; + return initializer; } template inline constexpr vec operator/(const vec& left, T f) { - T initializer[size]; + vec initializer{}; for (uint32_t i = 0; i < size; i++) initializer[i] = left[i] / f; - return vec{initializer}; + return initializer; } template