martinus / robin-hood-hashing

Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20
https://gitter.im/martinus/robin-hood-hashing
MIT License
1.5k stars 142 forks source link

robin_hood::hash returns different result for smart ptr and raw pointer. #83

Closed feverzsj closed 3 years ago

feverzsj commented 3 years ago
auto u = std::make_unique<int>();
assert(robin_hood::hash<decltype(u)>()(u) == robin_hood::hash<int*>()(u.get()));

since robin_hood::hash is only specialized on raw pointer and leaves unique_ptr cases to general implementation, the result is surprisingly different. This also happens to string/string_view/...

The obvious issue with this is we can't implement heterogeneous hash easily by directly using robin_hood::hash.

martinus commented 3 years ago

Hi, thanks for the report! I've now implemented hash for smart pointer and string views, and more generic version for strings.

It should work with the latest version: https://github.com/martinus/robin-hood-hashing/blob/master/src/include/robin_hood.h

martinus commented 3 years ago

Fixed in release 3.8.0