10#ifndef XTENSOR_EVAL_HPP
11#define XTENSOR_EVAL_HPP
13#include "xexpression_traits.hpp"
15#include "xtensor_forward.hpp"
30 using is_container = std::is_base_of<xcontainer<std::remove_const_t<T>>, T>;
46 inline auto eval(T&&
t) -> std::enable_if_t<detail::is_container<std::decay_t<T>>::value, T&&>
48 return std::forward<T>(
t);
53 inline auto eval(T&& t)
54 -> std::enable_if_t<!detail::is_container<std::decay_t<T>>::value, temporary_type_t<T>>
56 return std::forward<T>(t);
67 template <layout_type L = layout_type::any,
class E>
68 constexpr bool has_same_layout()
73 template <layout_type L = layout_type::any,
class E>
74 constexpr bool has_same_layout(E&&)
76 return has_same_layout<L, E>();
79 template <
class E1,
class E2>
80 constexpr bool has_same_layout(E1&&, E2&&)
82 return has_same_layout<std::decay_t<E1>::static_layout, E2>();
90 constexpr bool has_fixed_dims()
92 return detail::is_array<typename std::decay_t<E>::shape_type>::value;
96 constexpr bool has_fixed_dims(E&&)
98 return has_fixed_dims<E>();
105 template <
class E, layout_type L>
106 using as_xarray_container_t = xarray<typename std::decay_t<E>::value_type, layout_remove_any(L)>;
112 template <
class E, layout_type L>
113 using as_xtensor_container_t =
xtensor<
114 typename std::decay_t<E>::value_type,
115 std::tuple_size<typename std::decay_t<E>::shape_type>::value,
116 layout_remove_any(L)>;
148 template <layout_type L = layout_type::any,
class E>
150 -> std::enable_if_t<has_data_interface<std::decay_t<E>>::value && detail::has_same_layout<L, E>(), E&&>
152 return std::forward<E>(
e);
156 template <layout_type L = layout_type::any,
class E>
157 inline auto as_strided(E&& e) -> std::enable_if_t<
158 (!(has_data_interface<std::decay_t<E>>::value && detail::has_same_layout<L, E>()))
159 && detail::has_fixed_dims<E>(),
160 detail::as_xtensor_container_t<E, L>>
165 template <layout_type L = layout_type::any,
class E>
166 inline auto as_strided(E&& e) -> std::enable_if_t<
167 (!(has_data_interface<std::decay_t<E>>::value && detail::has_same_layout<L, E>()))
168 && (!detail::has_fixed_dims<E>()),
169 detail::as_xarray_container_t<E, L>>
auto eval(T &&t) -> std::enable_if_t< detail::is_container< std::decay_t< T > >::value, T && >
Force evaluation of xexpression.
auto as_strided(E &&e) -> std::enable_if_t< has_data_interface< std::decay_t< E > >::value &&detail::has_same_layout< L, E >(), E && >
Force evaluation of xexpression not providing a data interface and convert to the required layout.
standard mathematical functions for xexpressions
xtensor_container< uvector< T, A >, N, L > xtensor
Alias template on xtensor_container with default parameters for data container type.