Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
pos-idx.hh
1#pragma once
2
3#include <cinttypes>
4#include <functional>
5
6namespace nix {
7
8class PosIdx
9{
10 friend struct LazyPosAcessors;
11 friend class PosTable;
12 friend class std::hash<PosIdx>;
13
14private:
15 uint32_t id;
16
17 explicit PosIdx(uint32_t id)
18 : id(id)
19 {
20 }
21
22public:
23 PosIdx()
24 : id(0)
25 {
26 }
27
28 explicit operator bool() const
29 {
30 return id > 0;
31 }
32
33 auto operator<=>(const PosIdx other) const
34 {
35 return id <=> other.id;
36 }
37
38 bool operator==(const PosIdx other) const
39 {
40 return id == other.id;
41 }
42
43 size_t hash() const noexcept
44 {
45 return std::hash<uint32_t>{}(id);
46 }
47};
48
49inline PosIdx noPos = {};
50
51}
52
53namespace std {
54
55template<>
56struct hash<nix::PosIdx>
57{
58 std::size_t operator()(nix::PosIdx pos) const noexcept
59 {
60 return pos.hash();
61 }
62};
63
64} // namespace std
Definition pos-idx.hh:9
friend struct LazyPosAcessors
Definition pos-idx.hh:10