title: C++ partial template specialization in combination with std::is_base_of and std::enable_if
body: <p>Let's say I have a two classes: <code>Serializable</code> and <code>Printable</code>.</p>
  
  <p>So a simple template function which accepts all derived classes of <code>Printable</code> could look like:</p>
  
  <pre><code>template &lt;class T, class B = Printable, class = typename std::enable_if&lt;std::is_base_of&lt;B,     T&gt;::value&gt;::type&gt;
  void print(T value) {
      cout &lt;&lt; value &lt;&lt; endl;
  }
  </code></pre>
  
  <p>However, if I want it to accept also all derived classes of <code>Serializable</code> while I still have control over the function body, this would obviously not work:</p>
  
  <pre><code>template &lt;class T, class B = Printable, class = typename std::enable_if&lt;std::is_base_of&lt;B,     T&gt;::value&gt;::type&gt;
  void print(T value) {
      cout &lt;&lt; value &lt;&lt; endl;
  }
  
  template &lt;class T, class B = Serializable, class = typename std::enable_if&lt;std::is_base_of&lt;B,     T&gt;::value&gt;::type&gt;
  void print(T value) {
      cout &lt;&lt; value &lt;&lt; endl;
  }
  
  // Error: Redefinition of ...
  </code></pre>
  
  <p>So I figured the remaining solutions for this problem are template specializations.</p>
  
  <p>But I just can't figure out, how I can specialize a template in combination with <code>std::is_base_of</code> and <code>std::enable_if</code>.</p>
  
  <p>I hope someone is willing to help me!</p>