是否可以将 vector 内容的所有权从一个 vector 转移到另一个 vector ?
vector<T> v1;
// fill v1
vector<T> v2 = OvertakeContents(v1);
// now v1 would be empty and v2 would have all the contents of v1
有拼接功能的列表是可以的。 对于整个 vector ,这在恒定时间内也应该是可能的。
如果不是,那为什么不呢?
最佳答案
关于c++ - 在 STL 容器内转移所有权?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1465970/