Skip to content

Instantly share code, notes, and snippets.

@meshell
Created February 22, 2016 21:28
Show Gist options
  • Save meshell/045b73cab38a16415391 to your computer and use it in GitHub Desktop.
Save meshell/045b73cab38a16415391 to your computer and use it in GitHub Desktop.
#include <vector>
// Until C++11
std::vector<int> v;
//v is swapped with its temporary copy, which is capacity optimal
std::vector<int>(v.begin(), v.end()).swap(v);
// Since C++11
std::vector<int> v2;
v2.shrink_to_fit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment