diff options
author | Jacques Lucke <jacques@blender.org> | 2021-11-24 19:49:33 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-11-24 19:49:33 +0300 |
commit | 499c24ce7530b484b103fa714e94fc72ef6acfc2 (patch) | |
tree | a11ff14a08ada12ffcf2a1b1033ca83a7f30d130 /source/blender/functions | |
parent | cbe9a87d282f8060670b2162a87995a255dda556 (diff) |
BLI: add slice method to index mask and generic span
Diffstat (limited to 'source/blender/functions')
-rw-r--r-- | source/blender/functions/FN_generic_span.hh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/functions/FN_generic_span.hh b/source/blender/functions/FN_generic_span.hh index e2c49697ba9..6f0147b7fb3 100644 --- a/source/blender/functions/FN_generic_span.hh +++ b/source/blender/functions/FN_generic_span.hh @@ -93,6 +93,11 @@ class GSpan { const int64_t new_size = std::max<int64_t>(0, std::min(size, size_ - start)); return GSpan(*type_, POINTER_OFFSET(data_, type_->size() * start), new_size); } + + GSpan slice(const IndexRange range) const + { + return this->slice(range.start(), range.size()); + } }; /** @@ -169,6 +174,11 @@ class GMutableSpan { const int64_t new_size = std::max<int64_t>(0, std::min(size, size_ - start)); return GMutableSpan(*type_, POINTER_OFFSET(data_, type_->size() * start), new_size); } + + GMutableSpan slice(IndexRange range) const + { + return this->slice(range.start(), range.size()); + } }; } // namespace blender::fn |