diff --git a/src/lol/math/transform.h b/src/lol/math/transform.h index 35a08192..b456a117 100644 --- a/src/lol/math/transform.h +++ b/src/lol/math/transform.h @@ -17,6 +17,8 @@ // --------------------------------------------------- // +#include + #include namespace lol @@ -34,7 +36,8 @@ struct LOL_ATTR_NODISCARD cmplx_t : public linear_ops::base typedef T element; typedef cmplx_t type; - inline constexpr cmplx_t() {} + inline constexpr cmplx_t() = default; + inline constexpr cmplx_t(cmplx_t const &) = default; inline constexpr cmplx_t(T X) : x(X), y(T(0)) {} inline constexpr cmplx_t(T X, T Y) : x(X), y(Y) {} @@ -82,9 +85,8 @@ struct LOL_ATTR_NODISCARD quat_t : public linear_ops::base typedef quat_t type; /* Default constructor and copy constructor */ - inline constexpr quat_t() : w(), x(), y(), z() {} - inline constexpr quat_t(quat_t const &q) - : w(q.w), x(q.x), y(q.y), z(q.z) {} + inline constexpr quat_t() = default; + inline constexpr quat_t(quat_t const &) = default; /* Explicit constructor for type conversion */ template @@ -257,9 +259,9 @@ template struct LOL_ATTR_NODISCARD sqt_t { /* Default constructor and copy constructor */ - inline constexpr sqt_t() : s(), q(), t() {} - inline constexpr sqt_t(sqt_t const &other) - : q(other.q), t(other.t), s(other.s) {} + inline constexpr sqt_t() = default; + inline constexpr sqt_t(sqt_t const &) = default; + inline constexpr sqt_t& operator =(const sqt_t&) = default; /* Explicit constructor for type conversion */ template diff --git a/src/lol/math/vector.h b/src/lol/math/vector.h index 2e6d9f4d..05bd4730 100644 --- a/src/lol/math/vector.h +++ b/src/lol/math/vector.h @@ -93,6 +93,25 @@ struct LOL_ATTR_NODISCARD vec_t } }; +/* + * Helper macros for vector type member functions + */ + +#define LOL_COMMON_MEMBER_OPS(first) \ + inline T& operator[](size_t n) { return (&this->first)[n]; } \ + inline T const& operator[](size_t n) const { return (&this->first)[n]; } \ + \ + /* An explicit assignment operator is now mandatory */ \ + inline type & operator =(type const &that) \ + { \ + for (int i = 0; i < type::count; ++i) \ + (*this)[i] = that[i]; \ + return *this; \ + } \ + \ + void printf() const; \ + std::string tostring() const; + /* The generic “vec_t” type, which is a fixed-size vector with no * swizzling. There's an override for N=2, N=3, N=4 that has swizzling. */ template @@ -113,6 +132,8 @@ struct LOL_ATTR_NODISCARD vec_t } inline ~vec_t() {} + LOL_COMMON_MEMBER_OPS(m_data[0]) + /* Explicit constructor that takes exactly N arguments thanks to SFINAE. */ template #if LOL_FEATURE_CXX11_SFINAE_FOR_CTORS @@ -164,9 +185,6 @@ struct LOL_ATTR_NODISCARD vec_t m_data[i] = T(0); } - inline T& operator[](size_t n) { return m_data[n]; } - inline T const& operator[](size_t n) const { return m_data[n]; } - static const vec_t zero; private: @@ -185,25 +203,6 @@ private: T m_data[count]; }; -/* - * Helper macros for vector type member functions - */ - -#define LOL_COMMON_MEMBER_OPS(first) \ - inline T& operator[](size_t n) { return (&this->first)[n]; } \ - inline T const& operator[](size_t n) const { return (&this->first)[n]; } \ - \ - /* Visual Studio insists on having an assignment operator. */ \ - inline type & operator =(type const &that) \ - { \ - for (int i = 0; i < type::count; ++i) \ - (*this)[i] = that[i]; \ - return *this; \ - } \ - \ - void printf() const; \ - std::string tostring() const; - /* * 2-element vectors */