title: Class template specialization in class scope?
body: <p>Why is the specialization S in A legal and S in B not?</p>
  
  <p>( if B is not commented out )
  GCC 4.8.1: error: explicit specialization in non-namespace scope ‘class B’</p>
  
  <pre><code>#include &lt;type_traits&gt;
  #include &lt;iostream&gt;
  
  class Y {};
  class X {};
  
  struct A {
    template&lt;class T, class = void&gt;
    class S;
  
    template&lt;class T&gt;
    struct S &lt; T, typename std::enable_if&lt; std::is_same&lt; Y, T &gt;::value &gt;::type &gt; 
    {
      int i = 0;
    };
  
    template&lt;class T&gt;
    struct S &lt; T, typename std::enable_if&lt; std::is_same&lt; X, T &gt;::value &gt;::type &gt; 
    {
      int i = 1;
    };
  };
  
  /*
  class B
  {
      template&lt;class T&gt;
      class S;
  
      template&lt;&gt;
      class S &lt; Y &gt; {};
  
      template&lt;&gt;
      class S &lt; X &gt; {};
  };
  */
  
  
  int main()
  {
      A::S&lt; X &gt; asd;
      std::cout &lt;&lt; asd.i &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p><a href="http://coliru.stacked-crooked.com/a/1d2c0ad8baeec7d8" rel="noreferrer">on coliru: B commented out</a></p>
  
  <p><a href="http://coliru.stacked-crooked.com/a/7524fe06f22f933b" rel="noreferrer">on coliru: with B (error)</a></p>