diff --git a/matrix/Matrix.hpp b/matrix/Matrix.hpp index 15548a1c3f..6ef16e3f20 100644 --- a/matrix/Matrix.hpp +++ b/matrix/Matrix.hpp @@ -90,9 +90,9 @@ public: return (*this); } - void copyTo(Type (&dst)[M*N]) const + void copyTo(Type dst [M*N]) const { - memcpy(dst, _data, sizeof(dst)); + memcpy(dst, _data, sizeof(Type)*M*N); } void copyToColumnMajor(Type (&dst)[M*N]) const diff --git a/test/copyto.cpp b/test/copyto.cpp index 0a9ccb20f7..47a209edc6 100644 --- a/test/copyto.cpp +++ b/test/copyto.cpp @@ -3,6 +3,13 @@ using namespace matrix; +namespace { +void doTheCopy(const Matrix& A, float array_A[6]) +{ + A.copyTo(array_A); +} +} + int main() { float eps = 1e-6f; @@ -32,7 +39,7 @@ int main() A(1,1) = 5; A(1,2) = 6; float array_A[6] = {}; - A.copyTo(array_A); + doTheCopy(A, array_A); float array_row[6] = {1, 2, 3, 4, 5, 6}; for (size_t i = 0; i < 6; i++) { TEST(fabs(array_A[i] - array_row[i]) < eps);