diff options
| author | gingerBill <bill@gingerbill.org> | 2021-07-08 23:15:07 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-07-08 23:15:07 +0100 |
| commit | 35230b1a11940117ee218066ef5cd11243a23456 (patch) | |
| tree | 8e3cc3ec2b5efd40352897bd5d5bbcccb60d1fbf /src/array.cpp | |
| parent | 7acbf8b7b9cfc1f3e63d330e4dac13b28f1310f2 (diff) | |
Add "Suggestion: Did you mean?" for selector expression typos
Diffstat (limited to 'src/array.cpp')
| -rw-r--r-- | src/array.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/array.cpp b/src/array.cpp index db51e2bfb..a7c9204b0 100644 --- a/src/array.cpp +++ b/src/array.cpp @@ -90,6 +90,19 @@ Slice<T> slice_from_array(Array<T> const &a) { return {a.data, a.count}; } template <typename T> +Slice<T> slice_array(Array<T> const &array, isize lo, isize hi) { + GB_ASSERT(0 <= lo && lo <= hi && hi <= array.count); + Slice<T> out = {}; + isize len = hi-lo; + if (len > 0) { + out.data = array.data+lo; + out.count = len; + } + return out; +} + + +template <typename T> Slice<T> slice_clone(gbAllocator const &allocator, Slice<T> const &a) { T *data = cast(T *)gb_alloc_copy_align(allocator, a.data, a.count*gb_size_of(T), gb_align_of(T)); return {data, a.count}; |