1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 09:11:47 +02:00
nix/src/libutil/std-hash.hh
Eelco Dolstra 02f0294be0 Fix most DoxyGen warnings
Helps with #11841.
2024-11-12 15:34:24 +01:00

27 lines
619 B
C++

#pragma once
/**
* @file
*
* Hashing utilities for use with `std::unordered_map`, etc. (i.e. low
* level implementation logic, not domain logic like Nix hashing).
*/
#include <functional>
namespace nix {
/**
* `hash_combine()` from Boost. Hash several hashable values together
* into a single hash.
*/
inline void hash_combine(std::size_t & seed) {}
template<typename T, typename... Rest>
inline void hash_combine(std::size_t & seed, const T & v, Rest... rest)
{
std::hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
hash_combine(seed, rest...);
}
} // namespace nix