excess专题

Effective STL 17 Use the swap trick to trim excess capacity

for vector vector<int>(v.begin(), v.end()).swap(v); for string string(s.begin(), s.end()).swap(s); both to clear a container and to reduce its capacity to the minmum your implementation offers. v