How do I concatenate two std::vector
s?
Add this one to your header file:
template vector concat(vector &a, vector &b) {
vector ret = vector();
copy(a.begin(), a.end(), back_inserter(ret));
copy(b.begin(), b.end(), back_inserter(ret));
return ret;
}
and use it this way:
vector a = vector();
vector b = vector();
a.push_back(1);
a.push_back(2);
b.push_back(62);
vector r = concat(a, b);
r will contain [1,2,62]