| 967 | |
| 968 | template <typename I> |
| 969 | array array::concrete_holder_<I>::get_range(int64_t start, int64_t end) const |
| 970 | { |
| 971 | if constexpr (impl::has_data_member_function_v<I> && !impl::is_scalar_v<I> && |
| 972 | !impl::has_is_none_member_variable_v<I>) { |
| 973 | auto s = impl_.shape(); |
| 974 | ASSERT(!s.empty()); |
| 975 | auto v = |
| 976 | std::accumulate(s.begin() + 1, s.end(), 1UL, std::multiplies<uint64_t>()) * nd::dtype_bytes(impl_.dtype()); |
| 977 | auto d = impl_.data().data(); |
| 978 | auto sh = icm::small_vector<int64_t>(s.begin(), s.end()); |
| 979 | sh[0] = end - start; |
| 980 | static_assert(impl::has_owner_member_function_v<I>); |
| 981 | return array(impl::std_span_array_nd( |
| 982 | impl_.owner(), std::span<const uint8_t>(d + start * v, (end - start) * v), icm::shape(sh), impl_.dtype())); |
| 983 | } else { |
| 984 | throw invalid_operation("range() method is not implemented for this array."); |
| 985 | } |
| 986 | } |
| 987 | |
| 988 | } // namespace nd |
| 989 |
no test coverage detected