title: Mixing template function overloading and inheritance
body: <p>The following code prints:</p>
  
  <pre><code>generic
  overload
  </code></pre>
  
  <p>But what I wanted is that the overload or the specialization were called in both cases, not the generic one. I'm not trying to mix overloading with template specialization, they're here together because none worked as I expected. Is there any template magic to accomplish this? </p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class Interface {};
  class Impl: public Interface {};
  
  class Bar
  {
  public:
      template&lt;typename T&gt; void foo(T&amp; t) {
          std::cout &lt;&lt; "generic\n";
      }
      void foo(Interface&amp; t) {
          std::cout &lt;&lt; "overload\n";
      }
  };
  template&lt;&gt; void Bar::foo&lt;Interface&gt;(Interface&amp; t) {
      std::cout &lt;&lt; "specialization\n";
  }
  
  int main() {
      Bar bar;
      Impl impl;
      Interface&amp; interface = impl;
      bar.foo(impl);
      bar.foo(interface);
      return 0;
  }
  </code></pre>