From 1b8b997fc59bf2f443ed34d22cb2d39b0772574f Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 10 Dec 2018 14:07:47 +0100 Subject: Fix vector copy constructors --- vector/vector.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vector/vector.cpp b/vector/vector.cpp index f422db2..0322ee2 100644 --- a/vector/vector.cpp +++ b/vector/vector.cpp @@ -36,7 +36,7 @@ basic_vec::basic_vec(const basic_vec& other) { static_assert(d >= n); this->fill(static_cast(0)); for (std::size_t i = 0; i < n; i++) { - this[i] = other[i]; + this->at(i) = other.at(i); } } @@ -103,12 +103,19 @@ template class vec: public basic_vec { public: vec(std::initializer_list l) : basic_vec(l) {} + + template + vec(const basic_vec& other) : basic_vec(other) {} }; template class vec3 : public basic_vec { public: vec3(std::initializer_list l) : basic_vec(l) {} + + template + vec3(const basic_vec& other) : basic_vec(other) {} + static vec3 cross(const vec3& rhs, const vec3& lhs); }; @@ -125,6 +132,10 @@ template class vec2: public basic_vec { public: vec2(std::initializer_list l) : basic_vec(l) {} + + template + vec2(const basic_vec& other) : basic_vec(other) {} + T angle(); static vec3 cross(const vec2& rhs, const vec2& lhs); }; -- cgit v1.2.1