qwe*_*esr 1 c++ pointers stl vector c++11
如果我有两个包含std :: unique_ptr <>的向量,有没有办法将向量b添加到向量a的末尾,从而删除向量b?
例如:
std::unique_ptr<std::vector<int>> a(&someintvector);
std::unique_ptr<std::vector<int>> b(&someotherintvector);
Run Code Online (Sandbox Code Playgroud)
我如何将向量b移动到向量a的末尾?
您将内容移动b到a:
std::move(std::begin(*b), std::end(*b), std::back_inserter(*a));
Run Code Online (Sandbox Code Playgroud)