Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_span.hh
| Show First 20 Lines • Show All 593 Lines • ▼ Show 20 Lines | public: | ||||
| constexpr MutableSpan slice(const int64_t start, const int64_t size) const | constexpr MutableSpan slice(const int64_t start, const int64_t size) const | ||||
| { | { | ||||
| BLI_assert(start >= 0); | BLI_assert(start >= 0); | ||||
| BLI_assert(size >= 0); | BLI_assert(size >= 0); | ||||
| const int64_t new_size = std::max<int64_t>(0, std::min(size, size_ - start)); | const int64_t new_size = std::max<int64_t>(0, std::min(size, size_ - start)); | ||||
| return MutableSpan(data_ + start, new_size); | return MutableSpan(data_ + start, new_size); | ||||
| } | } | ||||
| constexpr MutableSpan slice(IndexRange range) const | |||||
| { | |||||
| return this->slice(range.start(), range.size()); | |||||
| } | |||||
| /** | /** | ||||
| * Returns a new MutableSpan with n elements removed from the beginning. This invokes | * Returns a new MutableSpan with n elements removed from the beginning. This invokes | ||||
| * undefined behavior when n is negative. | * undefined behavior when n is negative. | ||||
| */ | */ | ||||
| constexpr MutableSpan drop_front(const int64_t n) const | constexpr MutableSpan drop_front(const int64_t n) const | ||||
| { | { | ||||
| BLI_assert(n >= 0); | BLI_assert(n >= 0); | ||||
| const int64_t new_size = std::max<int64_t>(0, size_ - n); | const int64_t new_size = std::max<int64_t>(0, size_ - n); | ||||
| ▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines | |||||