-
Notifications
You must be signed in to change notification settings - Fork 418
Open
Labels
Description
Motivation
It can make sense for users to move the data/storage out of an xcontainer
(for instance statically reshape an xt::xtensor<T, N>
to an xt::xtensor<T, 1>
).
Right now, we can do
xtensor<T, 1> new_tensor{std::move(old_tensor.storage()), {old_tensor.size()}, {1}};
But, as suggested by @JohanMabille, we cannot do
xtensor<T, 1> new_tensor(std::move(old_tensor).storage(), ...);
Or
xtensor<T, 2> some_func(....);
xtensor<T, 1> new_tensor(some_func().storage(), ...);
Proposed Implementation
Add one of the following overload to xcontainer
:
- a/ storage_type&& storage() noexcept&&;
- b/ storage_type storage() noexcept&&;
I can send a PR for this.