This is the minimal code that I can't fix:
template<typename T>
class A {
template<typename S>
class B{
};
template<>
class B<int> {
};
};
when I compile I get
error: explicit specialization in non-namespace scope 'class A<T>'
What am I doing wrong? How can I fix this?
EDIT: I've seen some other answers, but from what they suggested, I should do this:
template<typename T>
class A {
template<typename S>
class B{
};
};
template<typename T>
class A<T>::B<int> {
};
But that doesn't work either...
Unfortunately, this partial specialization is invalid C++.
You may see the form in your example in the wild because MSC supported it as an extension.
Here's an approach which demonstrates how you can remove the dependence of the parent class: