hash: add a variadic mix operator
This commit is contained in:
parent
dccc4fbbf7
commit
01e46c7725
21
hash.hpp
21
hash.hpp
@ -3,11 +3,10 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 2010-2015, Danny Robson <danny@nerdcruft.net>
|
||||
* Copyright 2010-2019, Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#ifndef __UTIL_HASH_HPP
|
||||
#define __UTIL_HASH_HPP
|
||||
#pragma once
|
||||
|
||||
#include "hash/murmur/murmur2.hpp"
|
||||
|
||||
@ -27,6 +26,18 @@ namespace cruft::hash {
|
||||
{
|
||||
return murmur2<std::uint64_t>::mix (a, b);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template <typename ValueT, typename ...ArgsT>
|
||||
constexpr ValueT
|
||||
mix (ValueT &&head, ValueT &&tail, ArgsT&&...args)
|
||||
{
|
||||
return mix (
|
||||
mix (
|
||||
std::forward<ValueT> (head),
|
||||
std::forward<ValueT> (tail)
|
||||
),
|
||||
std::forward<ArgsT> (args)...
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user