Make util::hash_combine and hash_sequence constexpr

This commit is contained in:
Nikita Lisitsa 2023-08-23 00:01:52 +03:00
parent 9f36dfc0e4
commit 8a7891d561

View file

@ -6,9 +6,9 @@
namespace psemek::util
{
inline void hash_combine(std::size_t & seed, std::size_t value)
constexpr void hash_combine(std::size_t & seed, std::size_t value)
{
static const std::size_t k = 0x9ddfea08eb382d69ULL;
constexpr std::size_t k = 0x9ddfea08eb382d69ULL;
std::size_t a = (value ^ seed) * k;
a ^= (a >> 47);
std::size_t b = (seed ^ a) * k;
@ -17,7 +17,7 @@ namespace psemek::util
}
template <typename Iterator, typename Hash = std::hash<std::decay_t<decltype(*std::declval<Iterator>())>>>
void hash_sequence(std::size_t & seed, Iterator begin, Iterator end, Hash hash = Hash{})
constexpr void hash_sequence(std::size_t & seed, Iterator begin, Iterator end, Hash hash = Hash{})
{
for (; begin != end; ++begin)
{