diff options
author | crupest <crupest@outlook.com> | 2023-12-16 21:05:42 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-12-16 21:05:42 +0800 |
commit | c9555b5649bd1e886f96276eb392d65fffe2eb47 (patch) | |
tree | 1adcb8efb151379c3c51c226a460a5adf01b581a /include/cru/common/Range.h | |
parent | 8f7505d7fd35058870a4a937ca9670e383778dca (diff) | |
download | cru-c9555b5649bd1e886f96276eb392d65fffe2eb47.tar.gz cru-c9555b5649bd1e886f96276eb392d65fffe2eb47.tar.bz2 cru-c9555b5649bd1e886f96276eb392d65fffe2eb47.zip |
Bootstrap subprocess.
Diffstat (limited to 'include/cru/common/Range.h')
-rw-r--r-- | include/cru/common/Range.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/include/cru/common/Range.h b/include/cru/common/Range.h index e61d90ca..edc2ec55 100644 --- a/include/cru/common/Range.h +++ b/include/cru/common/Range.h @@ -3,23 +3,22 @@ namespace cru { struct Range final { - constexpr static Range FromTwoSides(gsl::index start, gsl::index end) { + constexpr static Range FromTwoSides(Index start, Index end) { return Range(start, end - start); } - constexpr static Range FromTwoSides(gsl::index start, gsl::index end, - gsl::index offset) { + constexpr static Range FromTwoSides(Index start, Index end, Index offset) { return Range(start + offset, end - start); } constexpr Range() = default; - constexpr Range(const gsl::index position, const gsl::index count = 0) + constexpr Range(const Index position, const Index count = 0) : position(position), count(count) {} - gsl::index GetStart() const { return position; } - gsl::index GetEnd() const { return position + count; } + Index GetStart() const { return position; } + Index GetEnd() const { return position + count; } - void ChangeEnd(gsl::index new_end) { count = new_end - position; } + void ChangeEnd(Index new_end) { count = new_end - position; } Range Normalize() const { auto result = *this; @@ -30,14 +29,14 @@ struct Range final { return result; } - Range CoerceInto(gsl::index min, gsl::index max) const { - auto coerce = [min, max](gsl::index index) { + Range CoerceInto(Index min, Index max) const { + auto coerce = [min, max](Index index) { return index > max ? max : (index < min ? min : index); }; return Range::FromTwoSides(coerce(GetStart()), coerce(GetEnd())); } - gsl::index position = 0; - gsl::index count = 0; + Index position = 0; + Index count = 0; }; } // namespace cru |