Why doesn't the C++ standard specify that std::hash<T>
is specialized for char*
, const char*
, unsigned char*
, const unsigned char*
, etc? I.e., it would hash the contents of the C string until the terminating null is found.
Any harm in injecting my own specializations into the std
namespace for my own code?
char*
andunsigned char*
are unsafe in the context of hashing, others withconst
qualifier are fine. Do not inject intostd::
, just make specializations in your namespace. – Outwornconst char*
that yourstd::hash
stores? (std::hash
stores its key values as well as hashing them). How do you distinguish between null terminatedconst char*
and pointers to individual characters? – Animastd::hash
is just a functor object. It hashes its argument. It doesn't store it. – Irv