I have the following code in the header file:
template<typename A, typename B> class TemplateTest;
template<>
class TemplateTest<int, double>
{
public:
float operator() (float a);
};
The definition in the cpp file:
template<> // this is problematic line
float TemplateTest<int, double>::operator()(float a)
{
float b;
b = a + 5;
return b;
}
with the "template<>" in the definition, MSVC returns error C2910 as it interprets operator() as a template method instead of a method of a template class. GCC behaves similar. But Solaris CC requires the "template<>" (otherwise it issues error ' "template<>" syntax is required when explicitly specializing a member of ...'.
So my question is which one is correct and how to make the code compile on all these platforms.