Why isn't std::hash specialized for containers?

Viewed 138

I started looking into std::unordered_set today and quickly found that std::hash doesn't specialize for all types -- only for those types that are listed here, but I couldn't find the reasoning for why this is the case. Coming from a more pythonic background, it seems like such a hassle to force people to write their own hash function when all you want is a set of tuples.

So, why doesn't std::hash try to specialize for all built in types, or if not for all built in types, at least for the most popular containers: std::pair, std::tuple, &c. Couldn't the implementation at the very least just do something with the memory address of whatever you're trying to hash ?

0 Answers
Related