Matrix: fix warning if M == N (#146)

This fixes the warning appearing with GCC 10.2:

../../src/lib/matrix/matrix/Matrix.hpp:481:34: error: logical ‘and’ of equal expressions [-Werror=logical-op]
  481 |         for (size_t i = 0; i < M && i < N; i++) {
      |

I would prefered something with if constexpr but we don't have that yet
in because we're using C++14.
This commit is contained in:
Julian Oes 2020-08-24 14:19:43 +02:00 committed by GitHub
parent cd8ad1584c
commit e101edc0e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -478,7 +478,8 @@ public:
setZero();
Matrix<Type, M, N> &self = *this;
for (size_t i = 0; i < M && i < N; i++) {
const size_t min_i = M > N ? N : M;
for (size_t i = 0; i < min_i; i++) {
self(i, i) = 1;
}
}