mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-01-19 01:26:47 +02:00
Add std::hash<PosIdx>
This commit is contained in:
parent
6c9d62dceb
commit
64b46000ad
1 changed files with 23 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue