Skip to content
12 changes: 6 additions & 6 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 (assignable_to_expression<E1, E2>)
{
e2.derived_cast().assign_to(e1);
}
Expand Down Expand Up @@ -267,14 +267,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>
-> std::enable_if_t<strided_expression<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<!strided_expression<E1>, bool>
{
return false;
}
Expand Down Expand Up @@ -304,7 +304,7 @@ namespace xt
return std::is_reference<typename T::stepper::reference>::value;
}

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

Expand Down Expand Up @@ -1002,13 +1002,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<!strided_expression<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<strided_expression<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
6 changes: 3 additions & 3 deletions include/xtensor/core/xeval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ 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<data_interface_expression<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>()))
(!(data_interface_expression<std::decay_t<E>> && detail::has_same_layout<L, E>()))
&& detail::has_fixed_dims<E>(),
detail::as_xtensor_container_t<E, L>>
{
Expand All @@ -164,7 +164,7 @@ 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>()))
(!(data_interface_expression<std::decay_t<E>> && detail::has_same_layout<L, E>()))
&& (!detail::has_fixed_dims<E>()),
detail::as_xarray_container_t<E, L>>
{
Expand Down
35 changes: 19 additions & 16 deletions include/xtensor/core/xexpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,15 +525,18 @@ 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<strided_expression<E>, detail::expr_strides_type<E>, get_strides_type<shape_type>>::type;
using backstrides_type = typename std::
conditional_t<strided_expression<E>, detail::expr_backstrides_type<E>, get_strides_type<shape_type>>::type;
using inner_strides_type = typename std::
conditional_t<strided_expression<E>, detail::expr_inner_strides_type<E>, get_strides_type<shape_type>>::type;
using inner_backstrides_type = typename std::conditional_t<
strided_expression<E>,
detail::expr_inner_backstrides_type<E>,
get_strides_type<shape_type>>::type;
using storage_type = typename std::
conditional_t<container_expression<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 +641,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<strided_expression<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<strided_expression<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<data_interface_expression<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<data_interface_expression<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<data_interface_expression<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<data_interface_expression<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<data_interface_expression<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<

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we still need this indirection with latest MSVC. But we can check that in a dedicated PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

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<!addressable_to_expression<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, container_expression<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<!iterable_expression<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<iterable_expression<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<!addressable_to_expression<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<iterable_expression<S>>>
inline bool has_shape(const E& e, const S& shape)
{
return e.shape().size() == shape.size()
Expand Down
6 changes: 3 additions & 3 deletions include/xtensor/generators/xgenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace xt
*************************************/

template <xgenerator_concept E>
requires(without_memory_address_concept<E>)
requires(!addressable_to_expression<std::decay_t<E>>)
struct overlapping_memory_checker_traits<E>
{
static bool check_overlap(const E&, const memory_range&)
Expand Down Expand Up @@ -167,7 +167,7 @@ namespace xt

template <class E, class FE = F>
void assign_to(xexpression<E>& e) const noexcept
requires(has_assign_to_v<E, FE>);
requires(assignable_to_expression<E, FE>);

const functor_type& functor() const noexcept;

Expand Down Expand Up @@ -374,7 +374,7 @@ namespace xt
template <class F, class R, class S>
template <class E, class FE>
inline void xgenerator<F, R, S>::assign_to(xexpression<E>& e) const noexcept
requires(has_assign_to_v<E, FE>)
requires(assignable_to_expression<E, FE>)
{
e.derived_cast().resize(m_shape);
m_f.assign_to(e);
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 (data_interface_expression<std::decay_t<E>>)
{
std::copy(e.strides().crbegin(), e.strides().crend(), strides.begin());
}
Expand Down
9 changes: 5 additions & 4 deletions include/xtensor/misc/xset_operation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define XTENSOR_XSET_OPERATION_HPP

#include <algorithm>
#include <iterator>
#include <type_traits>

#include <xtl/xsequence.hpp>
Expand Down Expand Up @@ -93,7 +94,7 @@ namespace xt
*/
template <class E, class F>
inline auto isin(E&& element, F&& test_elements) noexcept
requires(has_iterator_interface_concept<F>)
requires(iterable_expression<F>)
{
auto lambda = detail::lambda_isin<std::is_lvalue_reference<F>::value>::make(std::forward<F>(test_elements
));
Expand All @@ -111,7 +112,7 @@ namespace xt
* @param test_elements_end iterator to the end of an array
* @return a boolean array
*/
template <class E, iterator_concept I>
template <class E, std::forward_iterator I>
inline auto isin(E&& element, I&& test_elements_begin, I&& test_elements_end) noexcept
{
auto lambda = [&test_elements_begin, &test_elements_end](const auto& t)
Expand Down Expand Up @@ -150,7 +151,7 @@ namespace xt
*/
template <class E, class F>
inline auto in1d(E&& element, F&& test_elements) noexcept
requires(has_iterator_interface_concept<F>)
requires(iterable_expression<F>)
{
XTENSOR_ASSERT(element.dimension() == 1ul);
XTENSOR_ASSERT(test_elements.dimension() == 1ul);
Expand All @@ -168,7 +169,7 @@ namespace xt
* @param test_elements_end iterator to the end of an array
* @return a boolean array
*/
template <class E, iterator_concept I>
template <class E, std::forward_iterator I>
inline auto in1d(E&& element, I&& test_elements_begin, I&& test_elements_end) noexcept
{
XTENSOR_ASSERT(element.dimension() == 1ul);
Expand Down
Loading
Loading