Consider the following code:
class Bar;
enum Values
{
ValA,
ValB, // ...
};
template< typename T >
struct Foo : virtual public Bar
{
};
template<>
struct Foo< ValA >
{
void doSomething();
};
If I define the implementation of doSomething()
in the header file, the program doesn't complain when I use Foo::doSomething()
. However, if I move the implementation to a cpp file, as follows, I get an error:
template<>
void Foo< ValA >::doSomething()
{
// ...
}
The error:
error: template-id 'doSomething<>' for 'void Foo<(Values)0u>::doSomething()' does not match any template declaration.
I'm not sure why this is failing. Moving the specialized implementation to a cpp file should not be a problem, I believe. I've done this before.