title: How to intentionally cause a compile-time error on template instantiation
body: <p>Sometimes when coding with C++ templates, you want to prevent users from instantiating a specific specialization or set of specializations, because the result would be nonsensical.  So you can define a (specific or partial) specialization whose definition, if instantiated, would cause a compiler error.  The goal would be, if a user "misuses" the template, to cause a compiler error right next to a comment in your header file explaining what not to do, rather than leaving the compiler to come up with some confusing error message by its own devices, or maybe allowing the questionable code to compile.</p>
  
  <p>Example:</p>
  
  <pre><code>template &lt;typename T&gt; struct MyClassTemplate {
    // ...
  };
  
  template &lt;typename T&gt; struct MyClassTemplate&lt;T*&gt; {
    // Do not use MyClassTemplate with a pointer type!
    typedef typename T::intentional_error err;
  };
  </code></pre>
  
  <p>There are a number of ways to do this (depending on whether your specialization is a complete or partial specialization of a class or function).  But the syntax used must (?) depend on a template parameter, or else the compiler will complain when it first parses the intentional-error definition.  The example above has a hole in that somebody could stubbornly define an <code>intentional_error</code> nested type or member typedef (though I'd say they would then deserve whatever problems come up as a result).  But if you use a trick too fancy, you're likely to get an indecipherable and/or misleading compiler error message, which mostly defeats the purpose.</p>
  
  <p>Are there better straightforward ways to disallow template instantiations?</p>
  
  <p>I'm aware that in C++0x, template Concepts and deleted function declarations will provide much better control over this sort of thing, but I'm looking for answers that are valid C++03.</p>