use a propper hash combiner
This commit is contained in:
parent
0ba1ecc9ac
commit
79ed3e5a8b
|
@ -183,6 +183,19 @@ public:
|
|||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template <class T>
|
||||
/**
|
||||
* @brief boost::hash_combine
|
||||
* @param seed
|
||||
* @param v
|
||||
*/
|
||||
inline void hash_combine(std::size_t& seed, const T& v)
|
||||
{
|
||||
std::hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
|
||||
}
|
||||
|
||||
template<>
|
||||
/**
|
||||
* @brief The hash struct specilizaton for SACN::Provenance
|
||||
|
@ -196,10 +209,10 @@ namespace std
|
|||
*/
|
||||
size_t operator()(sACN::DATA::data_header const& src) const noexcept
|
||||
{
|
||||
size_t h1 = hash<string>{}(src.source_name);
|
||||
size_t h2 = hash<uint16_t>{}(src.universe);
|
||||
size_t h3 = hash<uint8_t>{}(src.priority);
|
||||
size_t h = h1 ^ h2 ^ h3; // or use boost::hash_combine
|
||||
size_t h =0;
|
||||
hash_combine(h, src.source_name);
|
||||
hash_combine(h, src.universe);
|
||||
hash_combine(h, src.priority);
|
||||
return h;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue