aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/pos-idx.hh
blob: 406fc1b362ae93bda690bbb7d59f17bba4147b26 (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
49
50
#pragma once
///@file

#include <cinttypes>

namespace nix {

class PosIdx
{
    friend struct LazyPosAcessors;
    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 = {};

}