Skip to content

Commit 622265e

Browse files
committed
fix
1 parent df8d5d6 commit 622265e

1 file changed

Lines changed: 8 additions & 45 deletions

File tree

include/xtensor/views/index_mapper.hpp

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ namespace xt
193193
* @throws Assertion failure if `i != 0` for integral slices.
194194
* @throws Assertion failure if `i >= slice.size()` for non-integral slices.
195195
*/
196-
template <size_t I, access_t ACCESS, std::integral Index>
196+
template <size_t I, std::integral Index>
197197
size_t map_ith_index(const view_type& view, const Index i) const;
198198

199199
/**
@@ -490,16 +490,16 @@ namespace xt
490490
{
491491
if constexpr (ACCESS == access_t::SAFE)
492492
{
493-
return container.at(map_ith_index<Is, ACCESS>(view, indices[Is])...);
493+
return container.at(map_ith_index<Is>(view, indices[Is])...);
494494
}
495495
else
496496
{
497-
return container(map_ith_index<Is, ACCESS>(view, indices[Is])...);
497+
return container(map_ith_index<Is>(view, indices[Is])...);
498498
}
499499
}
500500

501501
template <class UnderlyingContainer, class... Slices>
502-
template <size_t I, access_t ACCESS, std::integral Index>
502+
template <size_t I, std::integral Index>
503503
auto
504504
index_mapper<xt::xview<UnderlyingContainer, Slices...>>::map_ith_index(const view_type& view, const Index i) const
505505
-> size_t
@@ -515,51 +515,14 @@ namespace xt
515515

516516
if constexpr (std::is_integral_v<current_slice>)
517517
{
518-
if constexpr (ACCESS == access_t::SAFE)
519-
{
520-
if (i != 0)
521-
{
522-
XTENSOR_THROW(std::out_of_range, "Index out of range in index_mapper access");
523-
}
524-
}
525-
else
526-
{
527-
assert(i == 0);
528-
}
518+
assert(i == 0);
529519
return size_t(slice);
530520
}
531-
else if constexpr (xt::detail::is_xall_slice<std::decay_t<current_slice>>::value)
532-
{
533-
return size_t(i);
534-
}
535521
else
536522
{
537523
using slice_size_type = typename current_slice::size_type;
538-
const auto slice_index = static_cast<slice_size_type>(i);
539-
540-
if constexpr (ACCESS == access_t::SAFE)
541-
{
542-
if constexpr (std::is_signed_v<slice_size_type>)
543-
{
544-
if (slice_index < 0 || slice_index >= slice.size())
545-
{
546-
XTENSOR_THROW(std::out_of_range, "Index out of range in index_mapper access");
547-
}
548-
}
549-
else if (slice_index >= slice.size())
550-
{
551-
XTENSOR_THROW(std::out_of_range, "Index out of range in index_mapper access");
552-
}
553-
}
554-
else
555-
{
556-
if constexpr (std::is_signed_v<slice_size_type>)
557-
{
558-
assert(slice_index >= 0);
559-
}
560-
assert(slice_index < slice.size());
561-
}
562-
return size_t(slice(slice_index));
524+
assert(i < slice.size());
525+
return size_t(slice(static_cast<slice_size_type>(i)));
563526
}
564527
}
565528
else
@@ -578,4 +541,4 @@ namespace xt
578541

579542
} // namespace xt
580543

581-
#endif // XTENSOR_INDEX_MAPPER_HPP
544+
#endif // XTENSOR_INDEX_MAPPER_HPP

0 commit comments

Comments
 (0)