title: Make C++ fail compilation on specific instantiation of template function
body: <p>I'm working on a project which has an template function as so:</p>
  
  <pre><code>template &lt;class T&gt; 
  T foo&lt;T&gt;(T val) { return someFunc(val); }
  
  template &lt;&gt;
  bool foo&lt;bool&gt;(bool val) { return otherFunc(val); };
  </code></pre>
  
  <p>Now, I have a class <code>Bar</code>, which I don't want to accept as input.  In fact, I want it to generate an easy to spot compile error.   The problem is that if I do this:</p>
  
  <pre><code>template &lt;&gt;
  Bar foo&lt;Bar&gt;(Bar val) { static_assert(false,"uh oh..."); }
  </code></pre>
  
  <p>It fails on every compile.  I found <a href="https://stackoverflow.com/a/3926854/7673414">https://stackoverflow.com/a/3926854/7673414</a>, which says that I need to make reference to the template type, otherwise the static assert always takes place.   The problem is I don't have a template type here.   If I do:</p>
  
  <pre><code>template&lt; typename T &gt;
  struct always_false { 
      enum { value = false };  
  };
  
  template &lt;&gt;
  Bar foo&lt;Bar&gt;(Bar val) { static_assert(always_false&lt;Bar&gt;::value,"uh oh..."); }
  </code></pre>
  
  <p>then it also always fails compiling.   Is there a way to ensure that an instantiation of the template with type <code>Bar</code> always causes a compile error?  </p>