hash: add a variadic mix operator

This commit is contained in:
Danny Robson 2019-05-12 07:52:39 +10:00
parent dccc4fbbf7
commit 01e46c7725

View File

@ -3,11 +3,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. * 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 #pragma once
#define __UTIL_HASH_HPP
#include "hash/murmur/murmur2.hpp" #include "hash/murmur/murmur2.hpp"
@ -27,6 +26,18 @@ namespace cruft::hash {
{ {
return murmur2<std::uint64_t>::mix (a, b); 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)...
);
}
}