aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/pos-idx.hh
blob: 9949f1dc51d02acc1baf450f36007bee81de57b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once

#include <cinttypes>

namespace nix {

class PosIdx
{
    friend class PosTable;

private:
    uint32_t id;

    explicit PosIdx(uint32_t id)
        : id(id)
    {
    }

public:
    PosIdx()
        : id(0)
    {
    }

    explicit operator bool() const
    {
        return id > 0;
    }

    bool operator<(const PosIdx other) const
    {
        return id < other.id;
    }

    bool operator==(const PosIdx other) const
    {
        return id == other.id;
    }

    bool operator!=(const PosIdx other) const
    {
        return id != other.id;
    }
};

inline PosIdx noPos = {};

}