diff options
author | eldritch horrors <pennae@lix.systems> | 2024-03-08 06:55:47 +0100 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-03-09 04:47:05 -0700 |
commit | d4c738fe4c587c3f09b0fda899f419f2de97ee2f (patch) | |
tree | 4e26ad39777ccb697c048a12d1c6ea02b58cfc12 /src/libexpr/pos-idx.hh | |
parent | 7673312ccc179825033e4458604ddd2e9ae8d162 (diff) |
Move `PodIdx` to `pos-idx.hh` and `PosTable` to `pos-table.hh`
(cherry picked from commit c62c21e29af20f1c14a59ab37d7a25dd0b70f69e)
Change-Id: Id4ea2fc33b0874b2f1f2a32cabcbeb0afa26808f
Diffstat (limited to 'src/libexpr/pos-idx.hh')
-rw-r--r-- | src/libexpr/pos-idx.hh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/libexpr/pos-idx.hh b/src/libexpr/pos-idx.hh new file mode 100644 index 000000000..9949f1dc5 --- /dev/null +++ b/src/libexpr/pos-idx.hh @@ -0,0 +1,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 = {}; + +} |