Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions include/xtensor/core/xassign.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ namespace xt
template <class E1, class E2>
inline void assign_xexpression(xexpression<E1>& e1, const xexpression<E2>& e2)
{
if constexpr (has_assign_to<E1, E2>::value)
if constexpr (has_assign_to<E1, E2>())
{
e2.derived_cast().assign_to(e1);
}
Expand Down Expand Up @@ -266,15 +266,14 @@ namespace xt
}

template <class E1, class E2>
inline auto is_linear_assign(const E1& e1, const E2& e2)
-> std::enable_if_t<has_strides<E1>::value, bool>
inline auto is_linear_assign(const E1& e1, const E2& e2) -> std::enable_if_t<has_strides<E1>(), bool>
{
return (E1::contiguous_layout && E2::contiguous_layout && linear_static_layout<E1, E2>())
|| (e1.is_contiguous() && e2.has_linear_assign(e1.strides()));
}

template <class E1, class E2>
inline auto is_linear_assign(const E1&, const E2&) -> std::enable_if_t<!has_strides<E1>::value, bool>
inline auto is_linear_assign(const E1&, const E2&) -> std::enable_if_t<!has_strides<E1>(), bool>
{
return false;
}
Expand Down Expand Up @@ -304,8 +303,8 @@ namespace xt
return std::is_reference<typename T::stepper::reference>::value;
}

static constexpr bool value = has_strides<T>::value
&& has_step_leading<typename T::stepper>::value && stepper_deref();
static constexpr bool value = has_strides<T>() && has_step_leading<typename T::stepper>::value
&& stepper_deref();
};

template <class T>
Expand Down Expand Up @@ -1002,13 +1001,13 @@ namespace xt
const strides_type& m_strides;
};

template <bool possible = true, class E1, class E2, std::enable_if_t<!has_strides<E1>::value || !possible, bool> = true>
template <bool possible = true, class E1, class E2, std::enable_if_t<!has_strides<E1>() || !possible, bool> = true>
loop_sizes_t get_loop_sizes(const E1& e1, const E2&)
{
return {false, true, 1, e1.size(), e1.dimension(), e1.dimension()};
}

template <bool possible = true, class E1, class E2, std::enable_if_t<has_strides<E1>::value && possible, bool> = true>
template <bool possible = true, class E1, class E2, std::enable_if_t<has_strides<E1>() && possible, bool> = true>
loop_sizes_t get_loop_sizes(const E1& e1, const E2& e2)
{
using shape_value_type = typename E1::shape_type::value_type;
Expand Down
7 changes: 3 additions & 4 deletions include/xtensor/core/xeval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,23 @@ namespace xt
*/
template <layout_type L = layout_type::any, class E>
inline auto as_strided(E&& e)
-> std::enable_if_t<has_data_interface<std::decay_t<E>>::value && detail::has_same_layout<L, E>(), E&&>
-> std::enable_if_t<has_data_interface<std::decay_t<E>>() && detail::has_same_layout<L, E>(), E&&>
{
return std::forward<E>(e);
}

/// @cond DOXYGEN_INCLUDE_SFINAE
template <layout_type L = layout_type::any, class E>
inline auto as_strided(E&& e) -> std::enable_if_t<
(!(has_data_interface<std::decay_t<E>>::value && detail::has_same_layout<L, E>()))
&& detail::has_fixed_dims<E>(),
(!(has_data_interface<std::decay_t<E>>() && detail::has_same_layout<L, E>())) && detail::has_fixed_dims<E>(),
detail::as_xtensor_container_t<E, L>>
{
return e;
}

template <layout_type L = layout_type::any, class E>
inline auto as_strided(E&& e) -> std::enable_if_t<
(!(has_data_interface<std::decay_t<E>>::value && detail::has_same_layout<L, E>()))
(!(has_data_interface<std::decay_t<E>>() && detail::has_same_layout<L, E>()))
&& (!detail::has_fixed_dims<E>()),
detail::as_xarray_container_t<E, L>>
{
Expand Down
33 changes: 17 additions & 16 deletions include/xtensor/core/xexpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,15 +525,16 @@ namespace xt
using inner_shape_type = typename E::inner_shape_type;
using shape_type = typename E::shape_type;

using strides_type = xtl::mpl::
eval_if_t<has_strides<E>, detail::expr_strides_type<E>, get_strides_type<shape_type>>;
using backstrides_type = xtl::mpl::
eval_if_t<has_strides<E>, detail::expr_backstrides_type<E>, get_strides_type<shape_type>>;
using inner_strides_type = xtl::mpl::
eval_if_t<has_strides<E>, detail::expr_inner_strides_type<E>, get_strides_type<shape_type>>;
using inner_backstrides_type = xtl::mpl::
eval_if_t<has_strides<E>, detail::expr_inner_backstrides_type<E>, get_strides_type<shape_type>>;
using storage_type = xtl::mpl::eval_if_t<has_storage_type<E>, detail::expr_storage_type<E>, make_invalid_type<>>;
using strides_type = typename std::
conditional_t<has_strides<E>(), detail::expr_strides_type<E>, get_strides_type<shape_type>>::type;
using backstrides_type = typename std::
conditional_t<has_strides<E>(), detail::expr_backstrides_type<E>, get_strides_type<shape_type>>::type;
using inner_strides_type = typename std::
conditional_t<has_strides<E>(), detail::expr_inner_strides_type<E>, get_strides_type<shape_type>>::type;
using inner_backstrides_type = typename std::
conditional_t<has_strides<E>(), detail::expr_inner_backstrides_type<E>, get_strides_type<shape_type>>::type;
using storage_type = typename std::
conditional_t<has_storage_type<E>(), detail::expr_storage_type<E>, make_invalid_type<>>::type;

using stepper = typename E::stepper;
using const_stepper = typename E::const_stepper;
Expand Down Expand Up @@ -638,43 +639,43 @@ namespace xt
}

template <class T = E>
std::enable_if_t<has_strides<T>::value, const inner_strides_type&> strides() const
std::enable_if_t<has_strides<T>(), const inner_strides_type&> strides() const
{
return m_ptr->strides();
}

template <class T = E>
std::enable_if_t<has_strides<T>::value, const inner_strides_type&> backstrides() const
std::enable_if_t<has_strides<T>(), const inner_strides_type&> backstrides() const
{
return m_ptr->backstrides();
}

template <class T = E>
std::enable_if_t<has_data_interface<T>::value, pointer> data() noexcept
std::enable_if_t<has_data_interface<T>(), pointer> data() noexcept
{
return m_ptr->data();
}

template <class T = E>
std::enable_if_t<has_data_interface<T>::value, pointer> data() const noexcept
std::enable_if_t<has_data_interface<T>(), pointer> data() const noexcept
{
return m_ptr->data();
}

template <class T = E>
std::enable_if_t<has_data_interface<T>::value, size_type> data_offset() const noexcept
std::enable_if_t<has_data_interface<T>(), size_type> data_offset() const noexcept
{
return m_ptr->data_offset();
}

template <class T = E>
std::enable_if_t<has_data_interface<T>::value, typename T::storage_type&> storage() noexcept
std::enable_if_t<has_data_interface<T>(), typename T::storage_type&> storage() noexcept
{
return m_ptr->storage();
}

template <class T = E>
std::enable_if_t<has_data_interface<T>::value, const typename T::storage_type&> storage() const noexcept
std::enable_if_t<has_data_interface<T>(), const typename T::storage_type&> storage() const noexcept
{
return m_ptr->storage();
}
Expand Down
4 changes: 2 additions & 2 deletions include/xtensor/core/xfunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace xt
struct xcontainer_inner_types<xfunction<F, CT...>>
{
// Added indirection for MSVC 2017 bug with the operator value_type()
using func_return_type = typename meta_identity<
using func_return_type = typename std::type_identity<
decltype(std::declval<F>()(std::declval<xvalue_type_t<std::decay_t<CT>>>()...))>::type;
using value_type = std::decay_t<func_return_type>;
using reference = func_return_type;
Expand All @@ -156,7 +156,7 @@ namespace xt
template <class E>
struct overlapping_memory_checker_traits<
E,
std::enable_if_t<!has_memory_address<E>::value && is_specialization_of<xfunction, E>::value>>
std::enable_if_t<!has_memory_address<E>() && is_specialization_of<xfunction, E>::value>>
{
template <std::size_t I = 0, class... T, std::enable_if_t<(I == sizeof...(T)), int> = 0>
static bool check_tuple(const std::tuple<T...>&, const memory_range&)
Expand Down
2 changes: 1 addition & 1 deletion include/xtensor/core/xiterable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ namespace xt
};

template <class D>
using linear_iterator_traits = linear_iterator_traits_impl<D, has_storage_type<D>::value>;
using linear_iterator_traits = linear_iterator_traits_impl<D, has_storage_type<D>()>;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions include/xtensor/core/xmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,13 @@ namespace xt
namespace detail
{
template <class R, class T>
std::enable_if_t<!has_iterator_interface<R>::value, R> fill_init(T init)
std::enable_if_t<!has_iterator_interface<R>(), R> fill_init(T init)
{
return R(init);
}

template <class R, class T>
std::enable_if_t<has_iterator_interface<R>::value, R> fill_init(T init)
std::enable_if_t<has_iterator_interface<R>(), R> fill_init(T init)
{
R result;
std::fill(std::begin(result), std::end(result), init);
Expand Down
2 changes: 1 addition & 1 deletion include/xtensor/core/xsemantic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ namespace xt
template <class E>
struct overlapping_memory_checker_traits<
E,
std::enable_if_t<!has_memory_address<E>::value && is_crtp_base_of<xview_semantic, E>::value>>
std::enable_if_t<!has_memory_address<E>() && is_crtp_base_of<xview_semantic, E>::value>>
{
static bool check_overlap(const E& expr, const memory_range& dst_range)
{
Expand Down
2 changes: 1 addition & 1 deletion include/xtensor/core/xshape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace xt
* @param shape the shape to test
* @return bool
*/
template <class E, class S, class = typename std::enable_if_t<has_iterator_interface<S>::value>>
template <class E, class S, class = typename std::enable_if_t<has_iterator_interface<S>()>>
inline bool has_shape(const E& e, const S& shape)
{
return e.shape().size() == shape.size()
Expand Down
2 changes: 1 addition & 1 deletion include/xtensor/misc/xmanipulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ namespace xt
template <class E, class S, class X>
inline void compute_transposed_strides(E&& e, const S& shape, X& strides)
{
if constexpr (has_data_interface<std::decay_t<E>>::value)
if constexpr (has_data_interface<std::decay_t<E>>())
{
std::copy(e.strides().crbegin(), e.strides().crend(), strides.begin());
}
Expand Down
Loading
Loading