2020
2121#include " ../containers/xstorage.hpp"
2222#include " ../core/xtensor_config.hpp"
23+ #include " ../misc/xtl_concepts.hpp"
2324#include " ../utils/xutils.hpp"
2425
2526#ifndef XTENSOR_CONSTEXPR
@@ -426,7 +427,7 @@ namespace xt
426427 template <class R = std::ptrdiff_t , class T >
427428 inline auto keep (T&& indices)
428429 {
429- if constexpr (xtl::is_integral <std::decay_t <T>>::value )
430+ if constexpr (xtl::integral_concept <std::decay_t <T>>)
430431 {
431432 using slice_type = xkeep_slice<R>;
432433 using container_type = typename slice_type::container_type;
@@ -535,7 +536,7 @@ namespace xt
535536 template <class R = std::ptrdiff_t , class T >
536537 inline auto drop (T&& indices)
537538 {
538- if constexpr (xtl::is_integral <T>::value )
539+ if constexpr (xtl::integral_concept <T>)
539540 {
540541 using slice_type = xdrop_slice<R>;
541542 using container_type = typename slice_type::container_type;
@@ -574,11 +575,11 @@ namespace xt
574575 template <class MI = A, class MA = B, class STEP = C>
575576 auto get (std::size_t size) const
576577 {
577- if constexpr (xtl::is_integral <MI>::value && xtl::is_integral <MA>::value && xtl::is_integral <STEP>::value )
578+ if constexpr (xtl::integral_concept <MI> && xtl::integral_concept <MA> && xtl::integral_concept <STEP>)
578579 {
579580 return get_stepped_range (m_start, m_stop, m_step, size);
580581 }
581- else if constexpr (!xtl::is_integral <MI>::value && xtl::is_integral <MA>::value && xtl::is_integral <STEP>::value )
582+ else if constexpr (!xtl::integral_concept <MI> && xtl::integral_concept <MA> && xtl::integral_concept <STEP>)
582583 {
583584 return get_stepped_range (
584585 m_step > 0 ? 0 : static_cast <std::ptrdiff_t >(size) - 1 ,
@@ -587,30 +588,30 @@ namespace xt
587588 size
588589 );
589590 }
590- else if constexpr (xtl::is_integral <MI>::value && !xtl::is_integral <MA>::value && xtl::is_integral <STEP>::value )
591+ else if constexpr (xtl::integral_concept <MI> && !xtl::integral_concept <MA> && xtl::integral_concept <STEP>)
591592 {
592593 auto sz = static_cast <std::ptrdiff_t >(size);
593594 return get_stepped_range (m_start, m_step > 0 ? sz : -(sz + 1 ), m_step, size);
594595 }
595- else if constexpr (xtl::is_integral <MI>::value && xtl::is_integral <MA>::value && !xtl::is_integral <STEP>::value )
596+ else if constexpr (xtl::integral_concept <MI> && xtl::integral_concept <MA> && !xtl::integral_concept <STEP>)
596597 {
597598 return xrange<std::ptrdiff_t >(normalize (m_start, size), normalize (m_stop, size));
598599 }
599- else if constexpr (!xtl::is_integral <MI>::value && !xtl::is_integral <MA>::value && xtl::is_integral <STEP>::value )
600+ else if constexpr (!xtl::integral_concept <MI> && !xtl::integral_concept <MA> && xtl::integral_concept <STEP>)
600601 {
601602 std::ptrdiff_t start = m_step >= 0 ? 0 : static_cast <std::ptrdiff_t >(size) - 1 ;
602603 std::ptrdiff_t stop = m_step >= 0 ? static_cast <std::ptrdiff_t >(size) : -1 ;
603604 return xstepped_range<std::ptrdiff_t >(start, stop, m_step);
604605 }
605- else if constexpr (xtl::is_integral <MI>::value && !xtl::is_integral <MA>::value && !xtl::is_integral <STEP>::value )
606+ else if constexpr (xtl::integral_concept <MI> && !xtl::integral_concept <MA> && !xtl::integral_concept <STEP>)
606607 {
607608 return xrange<std::ptrdiff_t >(normalize (m_start, size), static_cast <std::ptrdiff_t >(size));
608609 }
609- else if constexpr (!xtl::is_integral <MI>::value && xtl::is_integral <MA>::value && !xtl::is_integral <STEP>::value )
610+ else if constexpr (!xtl::integral_concept <MI> && xtl::integral_concept <MA> && !xtl::integral_concept <STEP>)
610611 {
611612 return xrange<std::ptrdiff_t >(0 , normalize (m_stop, size));
612613 }
613- else if constexpr (!xtl::is_integral <MI>::value && !xtl::is_integral <MA>::value && !xtl::is_integral <STEP>::value )
614+ else if constexpr (!xtl::integral_concept <MI> && !xtl::integral_concept <MA> && !xtl::integral_concept <STEP>)
614615 {
615616 return xall<std::ptrdiff_t >(static_cast <std::ptrdiff_t >(size));
616617 }
@@ -755,11 +756,14 @@ namespace xt
755756 template <class T >
756757 struct cast_if_integer
757758 {
758- using type = std::conditional_t <xtl::is_integral <T>::value , std::ptrdiff_t , T>;
759+ using type = std::conditional_t <xtl::integral_concept <T>, std::ptrdiff_t , T>;
759760
760761 type operator ()(T t)
761762 {
762- return (xtl::is_integral<T>::value) ? static_cast <type>(t) : t;
763+ if constexpr (xtl::integral_concept<T>)
764+ return static_cast <std::ptrdiff_t >(t);
765+ else
766+ return t;
763767 }
764768 };
765769
0 commit comments