@@ -62,9 +62,8 @@ namespace xt
6262
6363 template <class S >
6464 using is_xslice = std::is_base_of<xslice<S>, S>;
65-
66- template <class E , class R = void >
67- using disable_xslice = typename std::enable_if<!is_xslice<E>::value, R>::type;
65+
66+ template <class S > concept xslice_concept = is_xslice<S>::value;
6867
6968 template <class ... E>
7069 using has_xslice = std::disjunction<is_xslice<E>...>;
@@ -850,60 +849,64 @@ namespace xt
850849 ******************************************************/
851850
852851 template <class S >
853- inline disable_xslice<S, std::size_t > get_size (const S&) noexcept
854- {
855- return 1 ;
856- }
857-
858- template <class S >
859- inline auto get_size (const xslice<S>& slice) noexcept
852+ inline std::size_t get_size (const S& slice) noexcept
860853 {
861- return slice.derived_cast ().size ();
854+ if constexpr (is_xslice<S>::value)
855+ {
856+ return 1 ;
857+ }
858+ else
859+ {
860+ return slice.size ();
861+ }
862862 }
863863
864864 /* ******************************************************
865865 * homogeneous step_size for integral types and slices *
866866 *******************************************************/
867867
868868 template <class S >
869- inline disable_xslice<S, std::size_t > step_size (const S&, std::size_t ) noexcept
870- {
871- return 0 ;
872- }
873-
874- template <class S >
875- inline disable_xslice<S, std::size_t > step_size (const S&, std::size_t , std::size_t ) noexcept
876- {
877- return 0 ;
878- }
879-
880- template <class S >
881- inline auto step_size (const xslice<S>& slice, std::size_t idx) noexcept
869+ inline std::size_t step_size (const S& slice, std::size_t idx) noexcept
882870 {
883- return slice.derived_cast ().step_size (idx);
871+ if constexpr (is_xslice<S>::value)
872+ {
873+ return slice.step_size (idx);
874+ }
875+ else
876+ {
877+ return 0 ;
878+ }
884879 }
885880
886881 template <class S >
887- inline auto step_size (const xslice<S>& slice, std::size_t idx, std::size_t n) noexcept
882+ inline std:: size_t step_size (const xslice<S>& slice, std::size_t idx, std::size_t n) noexcept
888883 {
889- return slice.derived_cast ().step_size (idx, n);
884+ if constexpr (is_xslice<S>::value)
885+ {
886+ return slice.step_size (idx, n);
887+ }
888+ else
889+ {
890+ return 0 ;
891+ }
890892 }
891893
892894 /* ********************************************
893895 * homogeneous value for integral and slices *
894896 *********************************************/
895897
896- template <class S , class I >
897- inline disable_xslice<S, std::size_t > value (const S& s, I) noexcept
898- {
899- return static_cast <std::size_t >(s);
900- }
901-
902898 template <class S , class I >
903899 inline auto value (const xslice<S>& slice, I i) noexcept
904900 {
905- using ST = typename S::size_type;
906- return slice.derived_cast ()(static_cast <ST>(i));
901+ if constexpr (is_xslice<S>::value)
902+ {
903+ using ST = typename S::size_type;
904+ return slice (static_cast <ST>(i));
905+ }
906+ else
907+ {
908+ return static_cast <std::size_t >(slice);
909+ }
907910 }
908911
909912 /* ***************************************
0 commit comments