The standard library promises, which, if you only call const -qualified member functions on the standard library object, the standard library code does not cause data race (see [res.on.data.races]).
The standard std::hash template, as well as all of its valid specializations, as well as any user-provided functor that meets the requirements of Hash ([hash.requirements]), must have a const -qualified call statement due to requirements, and thus using the std::hash specializations provided by the library should not cause a race. In addition, because of [namespace.std], specialized specializations must meet the same requirements.
Finally, I assume that you usually use guarantees of racial freedom by recursively calling const calls: if multiple threads are simultaneously viewing values ββon a map, they should use the map const interface to invoke the library rule above, but then the map only gets a constant hash value ( or private copy), and therefore she herself can only perform hashing without racing. Regardless of whether there is any explicit contactless call operator, it is invisible at this point.
source share