| 201 | } |
| 202 | |
| 203 | byte_t<4> byte_4_value(int64_t index) const override |
| 204 | { |
| 205 | if constexpr (impl::has_value_member_function_v<I, uint32_t> || |
| 206 | impl::has_value_member_function_v<I, int32_t> || |
| 207 | impl::has_value_member_function_v<I, float>) { |
| 208 | ASSERT(impl_.dtype() == dtype::uint32 || impl_.dtype() == dtype::int32 || |
| 209 | impl_.dtype() == dtype::float32); |
| 210 | return base::bit_cast<byte_t<4>>(impl_.value(index)); |
| 211 | } else if constexpr (impl::has_data_member_function_v<I>) { |
| 212 | return base::span_cast<const byte_t<4>>(impl_.data())[index]; |
| 213 | } else if constexpr (impl::has_get_member_function_v<I>) { |
| 214 | auto sh = shape(); |
| 215 | auto subvolume = std::accumulate(sh.begin() + 1, sh.end(), 1L, std::multiplies<int64_t>()); |
| 216 | return base::bit_cast<byte_t<4>>(get(index / subvolume).template value<uint32_t>(index % subvolume)); |
| 217 | } else { |
| 218 | throw invalid_operation("Can't convert array value to 4-byte."); |
| 219 | return byte_t<4>(); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | byte_t<8> byte_8_value(int64_t index) const override |
| 224 | { |