C++ newbie here. I'm pretty sure there's an easy and obvious solution to this problem, but even after reading through dozens of similar Q&As here, I haven't got closer to it. But here's my problem:
I have a template class:
template<class T>
struct KalmanSmoother
{
Eigen::MatrixX<T> P;
...
KalmanSmoother(int dynamParams, int measureParams, int controlParams = 0);
...
}
And I can use it without any problem, like this:
KalmanSmoother<float> smoother(4, 2);
smoother.P = Eigen::Matrix4f {
{0.1f, 0.0f, 0.1f, 0.0f},
{0.0f, 0.1f, 0.0f, 0.1f},
{0.1f, 0.0f, 0.1f, 0.0f},
{0.0f, 0.1f, 0.0f, 0.1f}
};
...
Works like charm. But when I want to refactor my code and I extract the initialization part into an other function, the compiler (MSVC 19.31.31104.0) starts crying. The function extraction looks like this:
// Declaration in the header:
void setupKalmanSmoother(KalmanSmoother<float> & smoother);
// Definition in the .cpp
inline void Vehicle::setupKalmanSmoother(KalmanSmoother<float> & smoother)
{
smoother.P = Eigen::Matrix4f {
{0.1f, 0.0f, 0.1f, 0.0f},
{0.0f, 0.1f, 0.0f, 0.1f},
{0.1f, 0.0f, 0.1f, 0.0f},
{0.0f, 0.1f, 0.0f, 0.1f}
};
...
}
And I'd just like to call it like this:
KalmanSmoother<float> smoother(4, 2);
setupKalmanSmoother(smoother);
Nothing magical. It should be working (I suppose...), but I get this compiler error:
error C7568: argument list missing after assumed function template 'KalmanSmoother'
The error message points to the declaration in the header. It's worth to mention that all function definitions of the template class are in the header file, since I have already run into - I think - exactly the same error when out of habit I put the definitions into the .cpp file.
So what am I missing?
Thanks in advance!!!