I have a sub_string
struct and I would like to use standard tools to calculate a hash of it:
struct sub_string
{
const char* ptr;
size_t size;
};
Here are some restrictions:
- It has to be done by standard tools provided by
c++11
. const char*
doesn't have to be NUL-terminated.- I don't want to use
std::hash<const char*>
specialization, since it computes a hash based on a pointer without content examination. - I don't want to create a new
std::string{ptr, size}
just to compute a hash. - I would like to have a
sub_string
hash value to be the same value asstd::string{ptr, size}
hash. - I don't want to touch implementation details of
std::string
.
How to do it?
Aucun commentaire:
Enregistrer un commentaire