小编Léo*_*nel的帖子

如何修复 eigen3 中的“非类型模板参数不是常量表达式”?

我还是 Eigen 库和 C++ 的新手。我正在测试一些代码,但我不明白为什么会这样

#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;
}
Run Code Online (Sandbox Code Playgroud)

不编译,而这

#include <iostream>
#include <Eigen/Dense>

using namespace std;

int main()
{
  const int SIZE_ = 2;
  Eigen::Matrix<float, SIZE_, SIZE_> test;
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

工作得很好。我如何更改第一个代码以使其工作(即 SIZE_ 将由一个可能具有不同值的变量启动)。

c++ c++11 eigen3

6
推荐指数
1
解决办法
2301
查看次数

标签 统计

c++ ×1

c++11 ×1

eigen3 ×1