The following gives an “Internal Compiler Error” on MSVC++ 10 Sp1.
And on gcc:
b.cpp:16:12: error: explicit specialization in non-namespace scope ‘struct A::B’
b.cpp:16:28: error: template-id ‘f’ in declaration of primary template
//class template
template< class T>
struct A{
//struct B {}; //Remove the comment and it will compile!
};
//partial specialization
template< class T >
struct A< T* >
{
struct B {
template<class C> void f(){}
//"Internal Compiler Error"
template<> void f<int>(){};
};
};
However, if the comments before struct B is removed it will compile!
I don’t understand the problem!
You have a bug in your code and MSVC++ isn’t coping with it. The gcc compile produces this:
In short, you can’t specialise inside a class or struct.
EDIT: A quick Google around suggests that MSVC++ allows such non-conforming constructs, but I guess they didn’t do a very good job of it.