xtensor icon indicating copy to clipboard operation
xtensor copied to clipboard

adding xt::detail::has_fixed_size and replacing is_array to expand supported types.

Open vakokako opened this issue 3 years ago • 1 comments

This pr adds type trait xt::detail::has_fixed_size to replace a common usage of xt::detail::is_array where implementation can benefit if the size of the container (usually used for shape) is known at compile time. This allows to add xt::sequence_view for example to supported types for shape in xt::adapt, but even much much more.

This also adds xt::detail::get_fixed_shape as a wrapper to std::tuple_size. The reason this is needed is that for example for xfunction that has fixed shape, we also want to use std::tuple_size, but we cannot partially specialize std::tuple_size only for the cases when xfunction has fixed shape.

auto tensor = xt::eval(xt::zeros<double>(xt::adapt(std::array<size_t, 2>{}) / 2));
// before decltype(tensor) == xarray
// after decltype(tensor) == xtensor

vakokako avatar Jul 18 '22 15:07 vakokako

The build only fails on the older msvc 19.0, but it's not clear why. It says use of undefined type 'xt::detail::get_fixed_size<T,void>', but this should use the specialization in xshape.hpp at line 399.

vakokako avatar Jul 27 '22 08:07 vakokako