-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding aliases xt::xtensor_pointer
and xt::xarray_pointer
#2665
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The names sound a bit like "pointers to tensor or array", but I don't have a better alternative for now.
@JohanMabille Is seems to me that In particular,
So the only way I see is to have template <class T, layout_type L, class SC>
using xarray_pointer = xarray_adaptor<xbuffer_adaptor<xtl::closure_type_t<T*>, xt::no_ownership, detail::default_allocator_for_ptr_t<T>>, L, SC>; which could be called as std::vector<size_t> shape = { 2, 2 };
std::vector<double> data = { 1, 2, 3, 4};
xt::xarray_pointer<double, XTENSOR_DEFAULT_LAYOUT, decltype(shape)> a = xt::adapt(data.data(), 4, xt::no_ownership(), shape); which I find very ugly. Do you know a way around this? Can a proper conversion be presented to the compiler? |
You can use
The only way to do it would be to provide an implicitconversion from |
bb1dbe0
to
0d22d13
Compare
Thanks. I went for the way of least resistance |
Thanks! Quite happy that we now have this. I have worked around it a few times already, but new enough to implement it. In particular because I did not realise it could be done so simply |
Fixes #2663
The name is up for discussion!