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.
vector<int>().swap(v);
string().swap(s);
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.
vector<int>().swap(v);
string().swap(s);