diff --git a/include/rotgen/impl/matrix_impl64.hpp b/include/rotgen/impl/matrix_impl64.hpp index e814c7c..07a3fce 100644 --- a/include/rotgen/impl/matrix_impl64.hpp +++ b/include/rotgen/impl/matrix_impl64.hpp @@ -44,7 +44,7 @@ namespace rotgen matrix_impl64& operator+=(matrix_impl64 const& rhs); matrix_impl64& operator-=(matrix_impl64 const& rhs); - matrix_impl64& operator-(); + matrix_impl64 operator-() const; matrix_impl64& operator*=(matrix_impl64 const& rhs); matrix_impl64& operator*=(double d); matrix_impl64& operator/=(double d); diff --git a/include/rotgen/matrix.hpp b/include/rotgen/matrix.hpp index 6018b13..9c78d00 100644 --- a/include/rotgen/matrix.hpp +++ b/include/rotgen/matrix.hpp @@ -29,6 +29,8 @@ namespace rotgen if constexpr(Cols != -1) assert(c == Cols && "Mismatched between dynamic and static column size"); } + matrix(parent const& base) : parent(base) {} + matrix(std::initializer_list> init) : parent(init) { if constexpr(Rows != -1) assert(init.size() == Rows && "Mismatched between dynamic and static row size"); @@ -75,9 +77,9 @@ namespace rotgen return *this; } - matrix& operator-() + matrix operator-() const { - return static_cast(*this).operator-(); + return matrix(static_cast(*this).operator-()); } matrix& operator*=(matrix const& rhs) diff --git a/src/matrix_impl64.cpp b/src/matrix_impl64.cpp index a5a69ad..658b22c 100644 --- a/src/matrix_impl64.cpp +++ b/src/matrix_impl64.cpp @@ -101,8 +101,7 @@ namespace rotgen return *this; } - matrix_impl64& matrix_impl64::operator-() - { + matrix_impl64 matrix_impl64::operator-() const { matrix_impl64 result(*this); result.storage_->data = -result.storage_->data; return result;