title: What's the point of forward declaring a class template explicit/partial specialization?
body: <p>The C++98 standard says:</p>
  
  <blockquote>
    <p>[temp.class.spec] Partial specialization declarations themselves are not found by name lookup.</p>
  </blockquote>
  
  <p>If this is also true for explicit specializations, this makes a forward-declaration of a class template explicit/partial specialization invisible.</p>
  
  <blockquote>
    <p>[temp.class.spec.match] When a class template is used in a context that requires an instantiation of the class, it is necessary to determine whether the instantiation is to be generated using the primary template or one of the partial specializations.</p>
  </blockquote>
  
  <p>This implies that the choice of explicit/partial specialization is not made until the point of (implicit) instantiation of a matching specialization - which only occurs when the class is required to be completely defined.</p>
  
  <p>In the following example, the only effect the forward-declared explicit-specializations have is to make the program fail to compile.</p>
  
  <pre><code>namespace N
  {
      template&lt;class T&gt;
      struct S
      {
      };
  
      typedef S&lt;char&gt; Type; // name lookup finds S&lt;T&gt;
  
      template&lt;&gt;
      struct S&lt;char&gt;; // invisible to name lookup
  
      typedef S&lt;char&gt; Type; // name lookup finds S&lt;T&gt;
  
      int f(S&lt;char&gt;*); // name lookup finds S&lt;T&gt;
  
      S&lt;int&gt; object; // implicitly instantiates S&lt;int&gt;
  
      template&lt;&gt;
      struct S&lt;int&gt;; // illegal, explicit specialization after instantiation
  }
  
  N::S&lt;char&gt;* p = 0; // name lookup finds N::S&lt;T&gt;
  int i = f(p); // name lookup finds N::f via ADL
  
  
  N::S&lt;char&gt; object; // illegal, incomplete type N::S&lt;char&gt;
  </code></pre>
  
  <p>In both cases, the only way to make the program compile (apart from deleting the specializations) is to provide a definition for both specializations <strong>before</strong> they are instantiated - which makes the forward-declaration a bit pointless.</p>
  
  <p>Does this behaviour have any practical real-world application? Apart from this, is there anything these forward-declarations are useful for?</p>