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

Move array hasher back to header file

Since it is a template function it needs to be in the header...
parent 4a6d5e01
Branches
No related tags found
No related merge requests found
......@@ -16,10 +16,20 @@ namespace std {
template <size_t N>
struct hash<std::array<int, N>> {
size_t operator()(const std::array<int, N>& key) const noexcept;
size_t 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;
}
};
} // std
void graphErrFunc(const char *msg);
template <class Ty>
......
......@@ -8,18 +8,6 @@ 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