I am still new to the Eigen library and C++. I am testing some code and I do not get why this
#include <iostream>
#include <Eigen/Dense>
using namespace std;
int main()
{
int a = 2;
const int SIZE_ = a;
Eigen::Matrix<float, SIZE_, SIZE_> test;
return 0;
}
does not compile, while this
#include <iostream>
#include <Eigen/Dense>
using namespace std;
int main()
{
const int SIZE_ = 2;
Eigen::Matrix<float, SIZE_, SIZE_> test;
return 0;
}
works perfectly fine. How could I change the first code so that it works (i.e. SIZE_ would be initiated by a variable that potentially could have a different value).
constexpr int SIZE_ = ...
so you immediately get the error (in casegetSizeOfMatrix()
was notconstexpr
) and not only when trying to declaretest
. – Muddle