Hi, While adding std::hash specialisations for Qt types, I ran into the (probably well-known) problem that the library does not lend a particularly helping hand for implementing your own. In particular, there's little-to-no support to hash memory regions and to combine hash values.
P0029R0 | A Unified Proposal for Composable Hashing |
The addition of a hash specialisation for std::string_view solves the first problem, because I can now hash contiguous memory without a memory allocation. To solve the second problem, I was thinking of using std::tie and hash the tuple, but to my surprise, the standard does not provide a hash specialisation for std::tuple. I have two questions: 1. Why is that (the std doesn't provide hash specialisations for all of its own types)?
2. Would it be acceptable to add a specialisation for std::tuple, so users could use std::tie as a way to combine hash values?
I get that hashing is an open problem, and a can of worms. But I am left to wonder why the third issue of modern C++ still appears to have no solution for hash combining (and am skeptical whether hashing std::string_views is really the intended way to hash raw memory).