title: hash for derived class
body: <p>I'm having a case where I derive a class without changing any of its data, so preserving the hash function of its parent would be just fine. However, this doesn't happen out of the box:</p>
  
  <pre><code>#include &lt;unordered_set&gt;
  
  struct A { size_t value; };
  struct B : public A {};
  
  namespace std
  {
      template&lt;&gt;
      struct hash&lt;A&gt;
      {
          typedef A argument_type;
          typedef size_t result_type;
          result_type operator()(argument_type const&amp; a) const noexcept { return a.value; }
      };
  }
  
  int main()
  {
      std::unordered_set&lt;A&gt; a_set; // works fine
      std::unordered_set&lt;B&gt; b_set; // error: hash&lt;B&gt; not found
  }
  </code></pre>
  
  <p>Is there a simple way of making this work without explicitly implementing <code>hash&lt;B&gt;</code>?</p>