I process some relatively large ints vectors, and I have one top-level vector that I need to copy the results of other (temporary) vectors into.
Expanding it in place, unfortunately, is not an option, since I get temporary vectors pre-prepared from another API, and I am stuck with GCC 4.1.2 for the same reason, so none of the sympathetic semantic movements or std :: move C ++ 11.
I am currently copying with an insert, something like:
vector<int> accumulator; for(){ vector<int> tempVector = vectReturningFunction(); ... if(!tempVector.empty()){ accumulator.insert(accumulator.end(), tempVector.begin(), tempVector.end()); } }
Since temp is usually one-time, and the data can be quite large, I would like to be able to move rather than copy, but I cannot figure out an elegant way to do this.
Any decisions or even just pointers (not intended for puns) in the useful direction would be greatly appreciated. I also have a vague recollection of how Struustrup pre C ++ 11 years ago redesigned the STL recipe to navigate STL containers, but these days there was nothing in C ++ 11.
Thanks.
c ++ stdvector move
ThE_JacO
source share