如果我有两个包含 std::unique_ptr<> 的 vector ,有没有办法将 vector b 添加到 vector a 的末尾,从而删除 vector b?
例如:
std::unique_ptr<std::vector<int>> a(&someintvector);
std::unique_ptr<std::vector<int>> b(&someotherintvector);
如何将 vector b 移动到 vector a 的末尾?
最佳答案
将 b
的内容移动到 a
中:
std::move(std::begin(*b), std::end(*b), std::back_inserter(*a));
关于c++ - 如何合并两个包含 std::unique_ptr 的 vector ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26317738/