Don't lose array sizes in copyTo

This commit is contained in:
Julian Kent
2019-09-17 12:21:20 +02:00
parent 51d2f9f0dc
commit b4714e2ed2
2 changed files with 10 additions and 3 deletions
+2 -2
View File
@@ -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
+8 -1
View File
@@ -3,6 +3,13 @@
using namespace matrix;
namespace {
void doTheCopy(const Matrix<float, 2, 3>& 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);