| 183 | } |
| 184 | |
| 185 | byte_t<2> byte_2_value(int64_t index) const override |
| 186 | { |
| 187 | if constexpr (impl::has_value_member_function_v<I, uint16_t> || |
| 188 | impl::has_value_member_function_v<I, int16_t>) { |
| 189 | ASSERT(impl_.dtype() == dtype::uint16 || impl_.dtype() == dtype::int16); |
| 190 | return base::bit_cast<byte_t<2>>(impl_.value(index)); |
| 191 | } else if constexpr (impl::has_data_member_function_v<I>) { |
| 192 | return base::span_cast<const byte_t<2>>(impl_.data())[index]; |
| 193 | } else if constexpr (impl::has_get_member_function_v<I>) { |
| 194 | auto sh = shape(); |
| 195 | auto subvolume = std::accumulate(sh.begin() + 1, sh.end(), 1L, std::multiplies<int64_t>()); |
| 196 | return base::bit_cast<byte_t<2>>(get(index / subvolume).template value<uint16_t>(index % subvolume)); |
| 197 | } else { |
| 198 | throw invalid_operation("Can't convert array value to 2-byte."); |
| 199 | return byte_t<2>(); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | byte_t<4> byte_4_value(int64_t index) const override |
| 204 | { |