Skip to content
Snippets Groups Projects
Commit 4a6d5e01 authored by Patrick M. Jensen's avatar Patrick M. Jensen
Browse files

Move array hasher defintion to util.cpp

parent a60de8d9
No related branches found
No related tags found
No related merge requests found
......@@ -16,16 +16,7 @@ namespace std {
template <size_t N>
struct hash<std::array<int, N>> {
size_t operator()(const std::array<int, N>& key) const
{
// Code from https://codereview.stackexchange.com/q/171999
static std::hash<int> hasher;
size_t result = 0;
for (int k : key) {
result = result * 31 + hasher(k);
}
return result;
}
size_t operator()(const std::array<int, N>& key) const noexcept;
};
} // std
......
......@@ -8,6 +8,18 @@ size_t std::hash<std::pair<int, int>>::operator()(const std::pair<int, int>& key
return hasher(tohash);
}
template <size_t N>
size_t std::hash<std::array<int, N>>::operator()(const std::array<int, N>& key) const noexcept
{
// Code from https://codereview.stackexchange.com/q/171999
static std::hash<int> hasher;
size_t result = 0;
for (int k : key) {
result = result * 31 + hasher(k);
}
return result;
}
void graphErrFunc(const char *msg)
{
// To avoid crashing the program we throw an exception here since Graph will otherwise call exit(1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment