1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 10:50:24 -04:00

Add std::hash<PosIdx>

This commit is contained in:
Robert Hensing 2024-07-16 16:46:41 +02:00
parent 6c9d62dceb
commit 64b46000ad

View file

@ -2,12 +2,15 @@
#include <cinttypes>
#include "util.hh"
namespace nix {
class PosIdx
{
friend struct LazyPosAcessors;
friend class PosTable;
friend class std::hash<PosIdx>;
private:
uint32_t id;
@ -37,8 +40,28 @@ public:
{
return id == other.id;
}
size_t hash() const noexcept
{
size_t h = 854125;
hash_combine(h, id);
return h;
}
};
inline PosIdx noPos = {};
}
namespace std {
template<>
struct hash<nix::PosIdx>
{
std::size_t operator()(nix::PosIdx pos) const noexcept
{
return pos.hash();
}
};
} // namespace std