Is there a default hash function for an unordered_set of a custom class?
I'm using a std::unordered_set 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 std::hash<Key> . I have a mySet member in one of my classes: typedef std::unordered_set<MyClass> USetType; USetType mySet; When I try to build, I get the following error: error C2440: 'type cast' : cannot convert from 'const MyClass' to 'size_t' Is it necessary to define a conversion function (to size_t ) if you want to use unordered_set with a custom class? Is there any way to avoid writing your own hash function and