Skip to content

Instantly share code, notes, and snippets.

@chiro-hiro
Created February 22, 2021 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiro-hiro/df0e0dabd80d368150ae56f3ec75f422 to your computer and use it in GitHub Desktop.
Save chiro-hiro/df0e0dabd80d368150ae56f3ec75f422 to your computer and use it in GitHub Desktop.
Which's one do you prefer?
std::vector<int> *vec = new std::vector<int>;
assert(vec != NULL);
// ...
delete vec;
std::vector<int> vec;
//...
vec.clear();
std::vector<int>().swap(vec);
std::vector<int> vec;
//...
vec.clear();
vec.shrink_to_fit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment