Created
February 22, 2016 21:28
-
-
Save meshell/045b73cab38a16415391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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