SyntaxFix
Write A Post
Hire A Developer
Questions
Adding to the above mentioned benefits of swap(). That clear() does not guarantee deallocation of memory. You can use swap() as follows:
swap().
clear()
swap()
std::vector<T>().swap(myvector);