title: C++ template specialization for interface
body: <p>Why won't the compiler select the Interface template when running the following code? Are additional declarations / hints needed or won't this work in general?</p>
  
  <p>I'm just curious if this is actually possible.</p>
  
  <pre><code>class Interface {
      public :
         virtual void Method() = 0;
         virtual ~Interface() { }
  };
  
  class Derived : Interface {
      public : 
         void Method() {
              cout&lt;&lt;"Interface method"&lt;&lt;endl;
         }
  };
  
  template&lt;typename T&gt; 
  struct Selector {
      static void Select(T&amp; o) {
          cout&lt;&lt;"Generic method"&lt;&lt;endl;
      }
  };
  
  template&lt;&gt; 
  struct Selector&lt;Interface&gt; {
      static void Select(Interface&amp; o) {
          o.Method();
      }
  };
  
  int i;
  Selector&lt;int&gt;::Select(i)       // prints out "Generic method" -&gt; ok
  Derived d;
  Selector&lt;Derived&gt;::Select(d);  // prints out "Generic method" -&gt; wrong
                                 // should be "Interface method"
  </code></pre>