mercredi 1 juin 2016

How to slice a vector in c++ and assign to itself?

I would like to know how I can replace the contents of a vector with a subset of that vector, without re-allocating a new vector (every question I have found appears to have the purpose of allocating a new vector)

example:

vector<int>* testVec = new vector<int>{1, 2, 3, 4, 5};
//do some operation to slice vector, to say {2, 3, 4} without re-allocating
//testVec should now have contents {2, 3, 4}

Aucun commentaire:

Enregistrer un commentaire