title: Can we determine at runtime if two type_info's would be castable?
body: <p>Is there a way to determine from two <code>const ::std::type_info</code> objects, let's name them <code>B</code> and <code>D</code> if the type described by D is derived from type B?</p>
  
  <p>I ask because I want to erase the type of an object I get but later on be able to check if it can be safely promoted.</p>
  
  <pre><code>void* data;
  const ::std::type_info* D;
  
  template&lt;typename D&gt;
  void store(D&amp;&amp; object)
  {
      D = &amp;typeid(object);
      data = ::std::addressof(object);
  }
  
  template&lt;typename B&gt;
  B&amp; load()
  {
      // if(typeid(B) != (*D)) throw ::std::bad_cast{};
      return *reinterpret_cast&lt;B*&gt;(data); // &lt;- also problematic
  }
  </code></pre>
  
  <p>I want to be able to use it like this:</p>
  
  <pre><code>class Base {};
  class Derived : Base {};
  
  Derived d;
  store(d);
  // ....
  load&lt;Base&gt;();
  </code></pre>
  
  <p>Thus it is not suitable to just use an equality compare for the typeids. I am pretty sure this could be possible in a similar way that dynamic_cast can figure this out. What I want is that in every case where <code>D&amp;</code> could be assigned to <code>B&amp;</code> allowing B as the type argument of <code>load()</code> - without knowing <code>D</code> at that time.</p>