Concatenating two std::vectors
问题 How do I concatenate two std::vector s? 回答1: vector1.insert( vector1.end(), vector2.begin(), vector2.end() ); 回答2: If you are using C++11, and wish to move the elements rather than merely copying them, you can use std::move_iterator along with insert (or copy): #include <vector> #include <iostream> #include <iterator> int main(int argc, char** argv) { std::vector<int> dest{1,2,3,4,5}; std::vector<int> src{6,7,8,9,10}; // Move elements from src to dest. // src is left in undefined but safe-to