00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_SHRINK_STL_VECTOR_INCLUDE
00013 #define MTL_SHRINK_STL_VECTOR_INCLUDE
00014
00015 namespace mtl {
00016
00018 template <typename Value, typename Allocator>
00019 void inline shrink_stl_vector(std::vector<Value, Allocator>& v)
00020 {
00021 if (v.capacity() > v.size()) {
00022 std::vector<Value, Allocator> tmp(v.begin(), v.end());
00023 swap(tmp, v);
00024 }
00025 }
00026
00027
00028 }
00029
00030 #endif // MTL_SHRINK_STL_VECTOR_INCLUDE