Content deleted Content added
No edit summary |
code --> source |
||
Line 205:
==Custom hash functions==
In order to use custom objects in std::unordered_map, a custom hash functor must be defined. This function takes a const reference to the custom type and returns a size_t
<source lang="cpp">
struct X{int i,j,k;};
Line 213:
}
};
</
The user defined function can be used as is in std::unordered_map, by passing it as a template parameter
<
Or can be set as the default hash function by specializing the std::hash function
<source lang="cpp">
namespace std {
template <>
Line 232:
//...
std::unordered_map<X,int> my_map;
</
==References==
|