title: Is there a default hash function for an unordered_set of a custom class?
body: <p>I'm using a <code>std::unordered_set</code> for the first time and have a question about the hash function. As far as I understand, if you don't specify a hash function it will default to <code>std::hash&lt;Key&gt;</code>.</p>
  
  <p>I have a <code>mySet</code> member in one of my classes:</p>
  
  <pre><code>typedef std::unordered_set&lt;MyClass&gt; USetType;
  USetType mySet;
  </code></pre>
  
  <p>When I try to build, I get the following error:</p>
  
  <blockquote>
    <p>error C2440: 'type cast' : cannot convert from 'const MyClass' to 'size_t'</p>
  </blockquote>
  
  <p>Is it necessary to define a conversion function (to <code>size_t</code>) if you want to use <code>unordered_set</code> with a custom class? Is there any way to avoid writing your own hash function and just using the default?</p>