std::vector and std::array store their data in contiguous blocks of memory. Suppose I have
class T; // A movable class
T t;
std::vector<T> vec;
vec.push_back(t);
std::array<T,1> arr;
Assuming like above that I am guaranteed to know that vec and arr have the same length. Is there a way that I can move vec to array instead of copy it with std::copy(vec.begin(), vec.end(), arr.begin())?
std::span(C++20) might interest you.