xtensor icon indicating copy to clipboard operation
xtensor copied to clipboard

No member named `crend` in `xt::fixed_shape<N>`

Open danielcjacobs opened this issue 10 months ago • 1 comments

Compiler: AppleClang 17.0.0 (clang 19.0.0) Xtensor version: 0.26.0 OS: macOS Sequoia 15.4

I used to be able to do operations with fixed shape arrays like in this snippet:

#include <xtensor/containers/xfixed.hpp>
#include <xtensor/containers/xtensor.hpp>
#include <xtensor/views/xview.hpp>

int main() {
	auto arr       = xt::xtensor<double, 1>({5, 5, 5, 5, 5});
	auto fixed_arr = xt::xtensor_fixed<double, xt::xshape<3> >{1, 2, 3};

	xt::view(arr, xt::range(0, 3)) = fixed_arr + 1;
}

However, this code no longer compiles, as I get this error about xt::fixed_shape not having a .crend() member:

In file included from foo.cpp:3:
In file included from subprojects/xtensor/include/xtensor/containers/xfixed.hpp:21:
In file included from subprojects/xtensor/include/xtensor/containers/../containers/xcontainer.hpp:22:
In file included from subprojects/xtensor/include/xtensor/containers/../containers/../core/xaccessible.hpp:13:
subprojects/xtensor/include/xtensor/containers/../containers/../core/../core/xstrides.hpp:781:35: error: no member named 'crbegin' in 'xt::fixed_shape<3>'
  781 |         auto src_iter = src_shape.crbegin();
      |                         ~~~~~~~~~ ^
subprojects/xtensor/include/xtensor/containers/../containers/../core/../core/../views/../core/../core/xassign.hpp:546:14: note: in instantiation of function template specialization 'xt::broadcastable<xt::fixed_shape<3>, std::array<unsigned long, 1>>' requested here
  546 |         if (!broadcastable(de2.shape(), de1.shape()))
      |              ^
subprojects/xtensor/include/xtensor/containers/../containers/../core/../core/../views/../core/../core/xassign.hpp:246:36: note: in instantiation of function template specialization 'xt::xexpression_assigner<xt::xtensor_expression_tag>::assert_compatible_shape<xt::xview<xt::xtensor_container<xt::uvector<double>, 1, xt::layout_type::row_major> &, xt::xrange<long>>, xt::xfunction<xt::detail::plus, const xt::xfixed_container<double, xt::fixed_shape<3>, xt::layout_type::row_major> &, xt::xscalar<int>>>' requested here
  246 |         xexpression_assigner<tag>::assert_compatible_shape(e1, e2);
      |                                    ^
subprojects/xtensor/include/xtensor/containers/../containers/../core/../core/../views/../core/xsemantic.hpp:728:13: note: in instantiation of function template specialization 'xt::assert_compatible_shape<xt::xview<xt::xtensor_container<xt::uvector<double>, 1, xt::layout_type::row_major> &, xt::xrange<long>>, xt::xfunction<xt::detail::plus, const xt::xfixed_container<double, xt::fixed_shape<3>, xt::layout_type::row_major> &, xt::xscalar<int>>>' requested here
  728 |         xt::assert_compatible_shape(*this, e);
      |             ^
subprojects/xtensor/include/xtensor/containers/../containers/../core/../core/../views/../core/xsemantic.hpp:513:37: note: in instantiation of function template specialization 'xt::xview_semantic<xt::xview<xt::xtensor_container<xt::uvector<double>, 1, xt::layout_type::row_major> &, xt::xrange<long>>>::assign_xexpression<xt::xfunction<xt::detail::plus, const xt::xfixed_container<double, xt::fixed_shape<3>, xt::layout_type::row_major> &, xt::xscalar<int>>>' requested here
  513 |         return this->derived_cast().assign_xexpression(e);
      |                                     ^
subprojects/xtensor/include/xtensor/containers/../containers/../core/../core/../views/../core/xsemantic.hpp:637:26: note: in instantiation of function template specialization 'xt::xsemantic_base<xt::xview<xt::xtensor_container<xt::uvector<double>, 1, xt::layout_type::row_major> &, xt::xrange<long>>>::assign<xt::xfunction<xt::detail::plus, const xt::xfixed_container<double, xt::fixed_shape<3>, xt::layout_type::row_major> &, xt::xscalar<int>>>' requested here
  637 |             return this->assign(e);
      |                          ^
subprojects/xtensor/include/xtensor/containers/../containers/../core/../core/../views/../core/xsemantic.hpp:790:24: note: in instantiation of function template specialization 'xt::xsemantic_base<xt::xview<xt::xtensor_container<xt::uvector<double>, 1, xt::layout_type::row_major> &, xt::xrange<long>>>::operator=<xt::xfunction<xt::detail::plus, const xt::xfixed_container<double, xt::fixed_shape<3>, xt::layout_type::row_major> &, xt::xscalar<int>>>' requested here
  790 |             base_type::operator=(rhs);
      |                        ^
subprojects/xtensor/include/xtensor/views/xview.hpp:935:31: note: in instantiation of function template specialization 'xt::xview_semantic<xt::xview<xt::xtensor_container<xt::uvector<double>, 1, xt::layout_type::row_major> &, xt::xrange<long>>>::operator=<xt::xfunction<xt::detail::plus, const xt::xfixed_container<double, xt::fixed_shape<3>, xt::layout_type::row_major> &, xt::xscalar<int>>>' requested here
  935 |         return semantic_base::operator=(e);
      |                               ^
foo.cpp:11:33: note: in instantiation of function template specialization 'xt::xview<xt::xtensor_container<xt::uvector<double>, 1, xt::layout_type::row_major> &, xt::xrange<long>>::operator=<xt::xfunction<xt::detail::plus, const xt::xfixed_container<double, xt::fixed_shape<3>, xt::layout_type::row_major> &, xt::xscalar<int>>>' requested here
   11 |         xt::view(arr, xt::range(0, 3)) = fixed_arr + 1;
      |                                        ^
In file included from foo.cpp:3:
In file included from subprojects/xtensor/include/xtensor/containers/xfixed.hpp:21:
In file included from subprojects/xtensor/include/xtensor/containers/../containers/xcontainer.hpp:22:
In file included from subprojects/xtensor/include/xtensor/containers/../containers/../core/xaccessible.hpp:13:
subprojects/xtensor/include/xtensor/containers/../containers/../core/../core/xstrides.hpp:784:38: error: no member named 'crend' in 'xt::fixed_shape<3>'
  784 |         for (; src_iter != src_shape.crend() && res; ++src_iter, ++dst_iter)
      |                            ~~~~~~~~~ ^
2 errors generated.

What's going on here and why is this happening when it was fine with previous versions of xtensor (up to 0.25.0)?

danielcjacobs avatar Apr 05 '25 23:04 danielcjacobs