diff --git a/components/misc/hash.hpp b/components/misc/hash.hpp index 30a9c41ee9..861df73772 100644 --- a/components/misc/hash.hpp +++ b/components/misc/hash.hpp @@ -1,15 +1,20 @@ #ifndef MISC_HASH_H #define MISC_HASH_H +#include +#include +#include + namespace Misc { /// Implemented similar to the boost::hash_combine - template - inline void hashCombine(std::size_t& seed, const T& v) + template + inline void hashCombine(Seed& seed, const T& v) { + static_assert(sizeof(Seed) >= sizeof(std::size_t), "Resulting hash will be truncated"); std::hash hasher; - seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); + seed ^= static_cast(hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2)); } } -#endif \ No newline at end of file +#endif