this question has answer here:
what's best way extend vector contents of vector returned function?
i can do:
std::vector<int> base; { std::vector<int> tmp = getvec(); //rvo make efficient base.reserve(base.size() + tmp.size()); base.insert(base.end(), std::make_move_iterator(tmp.begin()), std::make_move_iterator(tmp.end())); }
but possible without creating tmp? pass base in getvec reference, feel parameters should inputs , return value outputs. ideally able do:
base.extend(getvec());
but can't see how normal vector functions.
send vector want append parameter. used , accepted.
void func(vector<int>* master) { // generate values did in getvec() append original vector // instead of temp. while(generatingnumbers(i)) master->push_back(i); }
Comments
Post a Comment