diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2023-08-07 11:02:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-07 11:02:01 +0100 |
| commit | 77e5854a16ea9396752d784510169c5856f044ae (patch) | |
| tree | 61f1a2a43bd1ff52a1d7fa02bb4660e524221edf /src/array.cpp | |
| parent | cb5c8219898445a5501a95107c0200ea68b89a39 (diff) | |
| parent | 2a42dab108ea1c70962815cc714c0b4d3e42a719 (diff) | |
Merge branch 'master' into stdlib-parser-fixes
Diffstat (limited to 'src/array.cpp')
| -rw-r--r-- | src/array.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/array.cpp b/src/array.cpp index d8e25d25d..5d602cebc 100644 --- a/src/array.cpp +++ b/src/array.cpp @@ -168,6 +168,17 @@ gb_internal gb_inline Slice<T> slice(Slice<T> const &array, isize lo, isize hi) } return out; } +template <typename T> +gb_internal gb_inline Slice<T> slice(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> |