jeudi 24 décembre 2015

How to remove several elements from the end of std::vector?

Let's say I have a std::vector of integers:

std::vector<int> v;

v contains 100 elements, and I want to remove the last 10 elements. I can think of this solution:

v.erase(v.end() - 10, v.end());

Anything better?

Aucun commentaire:

Enregistrer un commentaire