I would like to wrap generator expressions in a function like in the following example.
inline auto build(int n) {
auto x = xt::make_xshared(xt::arange(n));
return x*x;
}
xt::xtensor<double, 1> array;
array = build(10);
Currently this gives an error
/usr/include/xtensor/xexpression.hpp:575:9: error:
‘class xt::xgenerator<xt::detail::arange_generator<int, int, int>, int,
std::array<long unsigned int, 1> >’ has no member named ‘linear_begin’
575 | XTENSOR_FORWARD_METHOD(linear_begin)
As far as I understand, this is currently only possible for xexpressions of evaluated expressions.
My current workarounds are:
- Evaluating the generator. This sacrifices laziness.
- Passing
array by reference. This is not idiomatic and only works if the assignment results in a evaluation.
I would like to wrap generator expressions in a function like in the following example.
Currently this gives an error
As far as I understand, this is currently only possible for xexpressions of evaluated expressions.
My current workarounds are:
arrayby reference. This is not idiomatic and only works if the assignment results in a evaluation.