diff options
Diffstat (limited to 'hash.hpp')
-rw-r--r-- | hash.hpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/hash.hpp b/hash.hpp new file mode 100644 index 00000000..c6d74444 --- /dev/null +++ b/hash.hpp @@ -0,0 +1,24 @@ +#pragma once +#include <cstdint> + +namespace Magnum::Examples { + +template<unsigned N = sizeof(std::size_t)*8> struct hash; + +template<> +struct hash<32> final { + [[maybe_unused]] + constexpr std::uint32_t operator()(std::uint32_t x) const noexcept { + return (std::uint32_t)x*0x9e3779b1u; + } +}; + +template<> +struct hash<64> final { + [[maybe_unused]] + constexpr std::uint64_t operator()(std::uint64_t x) const noexcept { + return x*0x9e3779b97f4a7c15ull; + } +}; + +} // namespace Magnum::Examples |