title: Where to declare partial specializations of class member templates?
body: <p>Here on stackoverflow I've found several comments (see for example the comment by <a href="https://stackoverflow.com/users/947836/jrok">jrok</a> on <a href="https://stackoverflow.com/questions/18904587/class-template-specialization-in-class-scope">this</a> question) stating that partial specializations of class member templates are allowed at non-namespace scope (in contrast to explicit specializations) like in the example below:</p>
  
  <pre><code>class A {
      template &lt;class T, class U&gt;
      class B {};
      template &lt;class U&gt;
      class B&lt;void, U&gt; {};
  };
  </code></pre>
  
  <p>Also, this example compiles just fine with both gcc and clang. However in the c++03 standard text I can only find 14.5.4 [temp.class.spec] §6 (or 14.5.5 §5 in c++11) about this issue:</p>
  
  <blockquote>
    <p>A class template partial specialization may be declared or redeclared in any namespace scope in which its definition may be defined (14.5.1 and 14.5.2).</p>
  </blockquote>
  
  <p>Along with the following example:</p>
  
  <pre><code>template&lt;class T&gt; struct A {
      class C {
          template&lt;class T2&gt; struct B { };
      };
  };
  
  // partial specialization of A&lt;T&gt;::C::B&lt;T2&gt;
  template&lt;class T&gt; template&lt;class T2&gt;
  struct A&lt;T&gt;::C::B&lt;T2*&gt; { };
  </code></pre>
  
  <p>So, how about class template partial specializations at non-namespace scope? Are they allowed by the standard? And where can I find the relevant text?</p>
  
  <p>Specifically, is my example valid (and would it still be valid if the enclosing class would be a template)? If not, are current compilers wrong to compile my example as stated above?</p>