Adding aliases xt::xtensor_pointer and xt::xarray_pointer#2665
Adding aliases xt::xtensor_pointer and xt::xarray_pointer#2665JohanMabille merged 2 commits intoxtensor-stack:masterfrom
xt::xtensor_pointer and xt::xarray_pointer#2665Conversation
JohanMabille
left a comment
There was a problem hiding this comment.
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!