.clear() will erase all elements in the vector, but it will not shrink the size of the vector. If you need to clear the vector and shrink the size, use the swap trick:
Code:
vector<something> v;
...
vector<something>().swap( v ); // Clear & minimize v.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.