Why does C++11 require a hash template specialization to define result_type
and argument_type
? I found some old code where a user-defined type is successfully used for an unordered_map<>
key but doesn't have these two typedef
's.
namespace std {
template<> struct hash<MyNamespace::Foo> {
typedef size_t result_type;
typedef MyNamespace::Foo argument_type;
size_t operator() (const MyNamespace::Foo& f ) const { return (size_t) f.u32InternalValue; }
};
}
Aucun commentaire:
Enregistrer un commentaire