title: How does `is_base_of` work?
body: <p>How does the following code work?</p>
  
  <pre><code>typedef char (&amp;yes)[1];
  typedef char (&amp;no)[2];
  
  template &lt;typename B, typename D&gt;
  struct Host
  {
    operator B*() const;
    operator D*();
  };
  
  template &lt;typename B, typename D&gt;
  struct is_base_of
  {
    template &lt;typename T&gt; 
    static yes check(D*, T);
    static no check(B*, int);
  
    static const bool value = sizeof(check(Host&lt;B,D&gt;(), int())) == sizeof(yes);
  };
  
  //Test sample
  class Base {};
  class Derived : private Base {};
  
  //Expression is true.
  int test[is_base_of&lt;Base,Derived&gt;::value &amp;&amp; !is_base_of&lt;Derived,Base&gt;::value];
  </code></pre>
  
  <ol>
  <li><p>Note that <code>B</code> is private base. How does this work? </p></li>
  <li><p>Note that <code>operator B*()</code> is const. Why is it important?</p></li>
  <li><p>Why is <code>template&lt;typename T&gt; static yes check(D*, T);</code> better than <code>static yes check(B*, int);</code> ? </p></li>
  </ol>
  
  <p><strong>Note</strong>: It is reduced version (macros are removed) of <code>boost::is_base_of</code>. And this works on wide range of compilers.</p>