Hello
This code below does not compile with VC++, although it compiles fine with gcc
foo.h
template<int TDegree>
class Base
{
public:
static const int dim = 3;
};
template<int TDim> class Vector {};
template<int TDegree>
class Foo : public Base<TDegree>
{
public:
typedef Base<TDegree> my;
void f(const Vector<my::dim>& v) const;
};
foo.cpp
#include "foo.h"
template<int TDegree>
void Foo<TDegree>::f(const Vector<my::dim>& v) const {}
// instantiation
template class Foo<1>;
The error message is
<source>(21): error C2244: 'Foo<TDegree>::f': unable to match function definition to an existing declaration
<source>(21): note: see declaration of 'Foo<TDegree>::f'
<source>(21): note: definition
<source>(21): note: 'void Foo<TDegree>::f(const Vector<Base<TDegree>::dim> &) const'
<source>(21): note: existing declarations
<source>(21): note: 'void Foo<TDegree>::f(const Vector<Base<TDegree>::dim> &) const'
The class signature is exactly identical in both header and cpp, so why this error emitted from the compiler?