title: C++ templates: how to determine if a type is suitable for subclassing
body: <p>Let's say I have some templated class depending on type <code>T</code>.  <code>T</code> could be almost anything: <code>int</code>, <code>int*</code>, <code>pair &lt;int, int&gt;</code> or <code>struct lol</code>; it cannot be <code>void</code>, a reference or anything cv-qualified though.  For some optimization I need to know if I can subclass <code>T</code>.  So, I'd need some trait type <code>is_subclassable</code>, determined as a logical combination of basic traits or through some SFINAE tricks.</p>
  
  <p>In the original example, <code>int</code> and <code>int*</code> are not subclassable, while <code>pair &lt;int, int&gt;</code> and <code>struct lol</code> are.</p>
  
  <p><strong>EDIT</strong>: As litb pointed out below, unions are also not subclassable and <code>T</code> can be a union type as well.</p>
  
  <p>How do I write the trait type I need?</p>