Adding reset_data to xbuffer_adaptor and reset_buffer to *adaptor to replace the pointer without any reallocation.#2521
Conversation
|
Grateful for your feedback @emmenlau . I'm not sure that I like the name of the method, happy to take suggestions. |
|
Restarting CI |
|
Looks good. The problem is it's not really discoverable with |
|
Thanks for your feedback @vakokako .
Do you mean documentation is lacking? Do you think that this PR sufficiently helps in that direction?
I see your point. Though for a view I don't really have a good syntax in mind. Anyway it's a separate enhancement I guess. Would you be willing to open an issue on that, with a suggested API? |
It's just hidden under the auto b = xt::adapt(&a.flat(0), std::array<size_t, 2>{2, 2});
b.replace(&a.flat(1)); // maybe could be called `move`?The types in xtensor are already hidden enough, without diving into code I wouldn't even know what type But I think this is a minor remark, thanks for implementing this pr! |
|
@JohanMabille Can you check that the edit is what you had in mind? |
replace to xbuffer_adaptor to replace the pointer without any reallocation.reset_data to xbuffer_adaptor and reset_buffer to *adaptor to replace the pointer without any reallocation.
…tor` to replace the pointer without any reallocation.
|
Awesome, thanks! |
Checklist
Description
Fixes #2519