If std::vector<> has shrink_to_fit() method, just use it instead of using the swap-with-a-temporary hack.