I have this trivial function templated on Scalar
type which in turn uses Eigen templates.
#include<Eigen/Core>
template<typename Scalar>
void somefunc(){
Eigen::Matrix<Scalar,9,1> v;
v.segment<3>(3).setZero();
}
When compiling with g++ -I/usr/include/eigen3 ex.cc
, I get
a.cc: In function ‘void somefunc()’:
a.cc:6:18: error: request for member ‘setZero’ in ‘3’, which is of non-class type ‘int’
v.segment<3>(3).setZero();
^~~~~~~
meaning the code was parsed as v.segment
[smaller-than]
3
[greater-than]
(3).setZero()
and not as template argument. I tried adding typename
in front of Eigen::Matrix
but it does not change anything.
What's wrong? I must be overlooking something obvious.