title: C++ template partial specialization with inheritance
body: <p>I need partial specialization of the <code>struct</code>, but I'd like also use some common functionality. For example, suppose I have the next type:</p>
  
  <pre><code>template &lt;typename A, typename B&gt;
  struct Foo  
  {
      Foo&amp; func0() { /* common actions with A and B */; return *this; }  
      void func1() { /* common actions with A and B */ }
      void func2() { /* common actions with A and B */ }
  }
  </code></pre>
  
  <p>Then I want specialize it for one of the template parameters - for example, I want consider special case when <code>B</code> is <code>int</code>, and I want to preserve <code>func0</code> and <code>func1</code> behaviour exactly the same as in common <code>Foo</code> (or course, <code>func0()</code> must return my specialized <code>Foo&amp;</code> for <code>int</code>), <code>func2</code> I want rewrite (suppose that I have more efficient implementation of it for integers), and I also want add <code>func3()</code> only for my specialized <code>Foo</code>.</p>
  
  <p>Of course, I can simpy write the following:</p>
  
  <pre><code>template &lt;typename A&gt;
  struct Foo&lt;A, int&gt;  
  {
      Foo&amp; func0() { /* common actions with A and B */; return *this; }  
      void func1() { /* common actions with A and B */ }
      void func2() { /* actions with A and 'int' */ }
      void func3() { /* actions with A and 'int' */ }
  }
  </code></pre>
  
  <p>but I'd like to avoid copy-paste in <code>func0</code> and <code>func1</code>.</p>
  
  <p>I also can rename common <code>Foo</code> to something like <code>FooBase</code> and simply inherit <code>Foo</code> from it, but in this case I can't use the common case as</p>
  
  <pre><code>Foo&lt;float, float&gt; a;
  </code></pre>
  
  <p>What methods does exist for allow me using both</p>
  
  <pre><code>Foo&lt;float, float&gt; a;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Foo&lt;float, int&gt; b;
  </code></pre>
  
  <p>without copying and pasting common <code>Foo</code>'s code to specialization?</p>
  
  <p>I'm interested in both c++11 and earlier standard compatibility.</p>