forked from cdacamar/fredbuf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.h
38 lines (30 loc) · 732 Bytes
/
types.h
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
#pragma once
#include "enum-utils.h"
namespace Editor
{
enum class Column : size_t
{
Beginning
};
enum class Length : size_t { };
enum class CharOffset : size_t
{
Sentinel = sentinel_for<CharOffset>
};
constexpr CharOffset operator+(CharOffset off, Length len)
{
return CharOffset{ rep(off) + rep(len) };
}
constexpr Length distance(CharOffset first, CharOffset last)
{
return Length{ rep(last) - rep(first) };
}
constexpr Length operator+(Length lhs, Length rhs)
{
return Length{ rep(lhs) + rep(rhs) };
}
constexpr Length operator-(Length lhs, Length rhs)
{
return Length{ rep(lhs) - rep(rhs) };
}
}