Created
October 12, 2016 16:25
-
-
Save danzimm/9e15c86487d7f217b85b759d4ce1b373 to your computer and use it in GitHub Desktop.
std::hash extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T, typename U> | |
struct std::hash<std::pair<T, U>> { | |
std::size_t operator()(std::pair<T, U> const& value) const { | |
std::size_t thash = std::hash<T>{}(value.first); | |
std::size_t uhash = std::hash<U>{}(value.second); | |
// See boost::hash_combine for this | |
return uhash ^ ( thash << 1 ); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment