I know that explicit specialization in non-namespace scope is forbidden by the standard. For example, this:
template <class A>
class Outer {
template <class B>
class Inner {};
template <>
class Inner<A> {};
};
Will give the Explicit specialization in non-namespace scope
error. I understand what is the error and how to avoid it with an extra dummy parameter (it could also be avoided by putting the Inner
class outside and adding an extra parameter to it, which I would like to avoid as certain older compilers have trouble with partial template specialization).
However, it seems that doing that gives actually more work to the compiler. My question is - why is explicit specialization in non-namespace scope forbidden? What was the motivation to impose this?
I understand that there are plenty more questions on the subject (C++: Nested template classes error "explicit specialization in non-namespace scope", Explicit specialization in non-namespace scope, C++: error "explicit specialization in non-namespace scope"), however I believe that mine is not a duplicate, as I do not ask how to fix the issue, like those questions do.