The correct way to code this construct is:
typedef int TypeA;
typedef float TypeB;
class MyClass
{
template <typename T>
T myFunction( int a, int b );
};
template <>
inline TypeA MyClass::myFunction<TypeA>(int a, int b) {}
template <>
inline TypeB MyClass::myFunction<TypeB>(int a, int b) {}
Note that the template member must be declared inside the class declaration, but specializations must be defined outside of it at the namespace level.
source
share