diff --git a/src/libexpr/pos-idx.hh b/src/libexpr/pos-idx.hh index e13491560..1d711681f 100644 --- a/src/libexpr/pos-idx.hh +++ b/src/libexpr/pos-idx.hh @@ -2,12 +2,15 @@ #include +#include "util.hh" + namespace nix { class PosIdx { friend struct LazyPosAcessors; friend class PosTable; + friend class std::hash; 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 +{ + std::size_t operator()(nix::PosIdx pos) const noexcept + { + return pos.hash(); + } +}; + +} // namespace std