In situations where performance can be ignored, some standard library containers still require a custom hash class for most of the types. Assume I have a type SomeType
defined somewhere, I want to use std::unordered_set
and I don't care about performance. The minimum I have to write is something like this:
template<typename T>
struct Hash42 {
size_t operator()(T const& e) {return 42;}
};
std::unordered_set<SomeType, Hash42<SomeType>> s;
有更短的版本吗?是否在某个地方定义了通用哈希类?