Add hash for geom::vector
This commit is contained in:
parent
ea46e820ab
commit
2f56f0caa2
1 changed files with 19 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/geom/detail/array.hpp>
|
||||
#include <psemek/util/hash.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <cstddef>
|
||||
|
|
@ -358,3 +359,21 @@ namespace psemek::geom
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
struct hash<::psemek::geom::vector<T, N>>
|
||||
{
|
||||
std::size_t operator()(::psemek::geom::vector<T, N> const & v) const noexcept
|
||||
{
|
||||
std::hash<T> h;
|
||||
std::size_t r = 0;
|
||||
for (std::size_t i = 0; i < N; ++i)
|
||||
::psemek::util::hash_combine(r, h(v[i]));
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue