Why is explicit namespace specialization prohibited?

I know that explicit specialization in a space other than a namespace is prohibited by the standard. For example, this:

template <class A>
class Outer {
    template <class B>
    class Inner {};

    template <>
    class Inner<A> {};
};

Gives an error Explicit specialization in non-namespace scope. I understand what an error is and how to avoid it with an additional parameter of a fictitious error (it can also be avoided by adding a class Innerand adding an additional parameter to it, which I would like to avoid, since some old compilers have problems with partial specialization by template).

However, this seems to give more work to the compiler. My question is why explicit specialization in a field without a namespace is prohibited ? What was the motivation to impose it?

I understand that there are still many questions on this subject ( C ++: an error in nested class templates and explicit specialization in a field without a namespace , Explicit specialization in a field without a namespace , C ++: error and an explicit specialization in a field without namespace However, I believe that mine is not duplicated , since I do not ask how to fix the problem, for example, these questions.

+4
source share

All Articles