title: How do you force a templatization to match a base class?
body: <p>I have a template function which is explicitly instantiated for <code>Base</code> class, but not for <code>Derived</code> class.  How can I force the uses that pass a <code>Derived</code> class (or other derived classes) to match against the <code>Base</code> class?</p>
  
  <p>Header file:</p>
  
  <pre><code>class Base {
  };
  class Derived : public Base {
  };
  class Derived2 : public Base {
  };
  
  template &lt;typename Example&gt; void function(Example &amp;arg);
  </code></pre>
  
  <p>Implementation file:</p>
  
  <pre><code>// Explicitly instantiate Base class:
  template void function&lt;Base&gt;(Base &amp;arg);
  
  // Define the template function:
  template &lt;typename Example&gt; void function(Example &amp;arg) {
    // Do something.
  }
  </code></pre>
  
  <p>Because I have not explicitly instantiated function for <code>Derived</code> or <code>Derived2</code>, I get undefined references, however, I would like to bind against the <code>Base</code> class which is explicitly defined.</p>
  
  <p>How can I force the template to resolve to the Base class for all objects derived from Base using C++-03?</p>
  
  <p>Can I do it somehow with a specialization of the <code>Derived</code> class to the <code>Base</code> class definition?</p>