Registered Member
|
Hi,
I'm having some strange issues in Visual Studio 2010 with code that works fine in gcc and clang. I'm wondering if anyone else has experienced this. Basically, I want to template a recursive function by the size of a vector, and then specialize the base case.
The original is code is more involved, so I distilled it to the essence of what is generating the problem, namely the following error in VS2010: "C2912: proj::foo<2>(...) is not a specialization of a function template" Basically, it looks like it is unable to match the specialized version of foo to the templated version, which doesn't make sense to me. I've tried all sorts of things, including templating on two numbers, N and M, in case VS2010 doesn't like using "N-1" inside the function signature? Any clues as to what's happening here? Any help would be much appreciated. |
Moderator
|
The template specialization should look like:
|
Registered Member
|
You mean by getting rid of the <2>? It shouldn't make a difference (and it fact, it doesn't. I still
get the same error in VS2010). I am unable to re-create this problem without using Eigen*, so that's why I posted here, in case it is a known thing when working with Eigen. Maybe it's just applying templates in a different order than gcc/clang. So that by the time this specialization is done, it sees parameters of Matrix<Real, 3, 1> and Matrix<Real, 2, 1>, which although derived from the same class, are distinct classes and make the function parameters not match. I think I can hack a workaround by passing the underlying pointers from data() and then re-wrapping them into an Eigen container, so that no Eigen object appears as a parameter. It's ugly but should work. Thanks. *I wrote a stupid test function to compute a factorial, but the input number is templated. It follows the same outline as above, but compiles and works fine in VS2010. If I add an Eigen Matrix parameter like above (even though it doesn't do anything), it won't compile anymore.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]