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