As far as I know MSVC is not always compliant and, as an extension, allows specialization of member functions inside a class.
MSVC is not generating the code when not explicitly told to. If you use that function member it will trigger the error, also if you explicitly specialize it or explicitly instantiate it:
template <typename T>
class MyClass {
public:
int getAlpha () { return m_alpha32 ; }
private:
int m_alpha1 ; // See the "1" here
};
template<> class MyClass<int>{ // Explicit specialization triggers the error
public:
int getAlpha () { return m_alpha32 ; }
private:
int m_alpha1 ; // See the "1" here
};
template class MyClass<int>; // Explicit instantiation, triggers the error
int main(){
MyClass<int> obj; // doesn't trigger the error alone
obj.getAlpha(); // trigger the error
return 0;
}
Also take a look here: http://msdn.microsoft.com/en-us/library/7y5ca42y(v=vs.110).aspx
The compiler generates code for a template class or function when the class or function is instantiated. A member function is instantiated when it is called, and a virtual member function is instantiated when its class is constructed. This can cause problems if you are building a library with templates for other users.
and also
A class template is first specialized and then instantiated by the compiler.
Thus either no diagnostic is being required or code isn't being generated at all.