Skip to content

Commit 4e67be4

Browse files
committed
Addressed comments
1 parent a35b0a2 commit 4e67be4

1 file changed

Lines changed: 8 additions & 20 deletions

File tree

include/xtensor/xstrided_view.hpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -809,22 +809,6 @@ namespace xt
809809

810810
namespace detail
811811
{
812-
// if shape is signed do the check
813-
template <class S, class R>
814-
using do_shape_recalculation = std::
815-
enable_if_t<std::is_signed<get_value_type_t<typename std::decay<S>::type>>::value, R>;
816-
817-
// if shape is unsigned pass through
818-
template <class S, class R>
819-
using no_shape_recalculation = std::
820-
enable_if_t<!std::is_signed<get_value_type_t<typename std::decay<S>::type>>::value, R>;
821-
822-
template <typename T>
823-
inline no_shape_recalculation<T, T> make_unsigned_shape(T shape)
824-
{
825-
return shape;
826-
}
827-
828812
template <typename S, typename Enable = void>
829813
struct rebind_shape;
830814

@@ -837,13 +821,16 @@ namespace xt
837821
template <class S>
838822
struct rebind_shape<S, std::enable_if_t<std::is_signed<get_value_type_t<typename std::decay_t<S>>>::value>>
839823
{
840-
using Shape = rebind_container_t<size_t, S>;
824+
using type = rebind_container_t<size_t, S>;
841825
};
842826

843-
template <class S, do_shape_recalculation<S, bool> = true>
827+
template <class S, std::
828+
enable_if_t<std::is_signed<get_value_type_t<typename std::decay<S>::type>>::value, bool> = true>
844829
inline auto recalculate_shape_impl(S& shape, size_t size)
845830
{
846831
using value_type = get_value_type_t<typename std::decay_t<S>>;
832+
const auto num_auto_dims = std::count(shape.cbegin(), shape.cend(), -1);
833+
XTENSOR_ASSERT(num_auto_dims <= 1);
847834
auto iter = std::find(shape.begin(), shape.end(), -1);
848835
if (iter != std::end(shape))
849836
{
@@ -854,7 +841,8 @@ namespace xt
854841
return shape;
855842
}
856843

857-
template <class S, no_shape_recalculation<S, bool> = true>
844+
template <class S, std::
845+
enable_if_t<!std::is_signed<get_value_type_t<typename std::decay<S>::type>>::value, bool> = true>
858846
inline auto recalculate_shape_impl(S& shape, size_t)
859847
{
860848
return shape;
@@ -876,7 +864,7 @@ namespace xt
876864
);
877865

878866
using shape_type = std::decay_t<decltype(shape)>;
879-
using unsigned_shape_type = typename detail::rebind_shape<shape_type>::Shape;
867+
using unsigned_shape_type = typename detail::rebind_shape<shape_type>::type;
880868
get_strides_t<unsigned_shape_type> strides;
881869

882870
detail::recalculate_shape(shape, e.size());

0 commit comments

Comments
 (0)