AB.reserve( A.size() + B.size() ); // preallocate memory
AB.insert( AB.end(), A.begin(), A.end() );
AB.insert( AB.end(), B.begin(), B.end() );
More Related Contents:
- How to find out if an item is present in a std::vector?
- Best way to extract a subvector from a vector?
- Removing item from vector, while in C++11 range ‘for’ loop?
- C++ Erase vector element by value rather than by position? [duplicate]
- Convert a vector to a string
- Vectors, structs and std::find
- iterate vector, remove certain items as I go
- Vectors and polymorphism in C++
- Does vector::erase() on a vector of object pointers destroy the object itself?
- Convert Mat to Array/Vector in OpenCV
- Vectors in Arduino
- Vector assignment crashing
- vector::size_type in C++
- Does std::vector *have* to move objects when growing capacity? Or, can allocators “reallocate”?
- splitting a string into an array in C++ without using vector
- Is it possible to initialize std::vector over already allocated memory?
- Initializer-list-constructing a vector of noncopyable (but movable) objects
- array vs vector vs list
- C++ N nested vectors at runtime
- How to read a file into vector in C++?
- What happens if you increment an iterator that is equal to the end iterator of an STL container
- Is std::vector memory freed upon a clear?
- C++ 2 dimensional array with variable size rows
- Multi-dimensional vector
- C++: Rotating a vector around a certain point
- std::vector capacity after copying
- vector memory allocation strategy
- How to create a vector of user defined size but with no predefined values?
- Why does using push_back on a vector declared with size result in a vector of zeros?
- What happen to pointers when vectors need more memory and realocate memory?