I'm writing a program that needs to perform a lot of hashes very fast, and in a threadsafe way. For whatever reason c++'s std::hash seems to require constructing a functor every time you want to hash a value
std::hash<std::string>{}(data);
I'm quite concerned about the overhead of allocating an entire struct every time I want to hash a value, but I don't understand the actual reason a functor is even necessary in this context.
Is it safe / correct to create one hash struct then call its operator() multiple different times?
std::hash<std::string> strHash;
strHash(data1);
strHash(data2);
Is re-using one hash struct going to be threadsafe? And if not, how would I make it more threadsafe?