Re:A brief introduction to C++'s model for type- and resourc...
by vvanders on Friday January 15, 2016 @12:02PM
(#10910515)
Yup, the spec is also really vague on if clear() actually releases memory. AFAIK the only "correct" way to actually clear a vector is "vec = std::vector<T>()" with the STL.
[ Parent
| on HN ]
Re:A brief introduction to C++'s model for type- and resourc...
by pragmatib on Friday January 15, 2016 @02:41PM
(#10911580)
Actually you'd have to try harder: even this might leave the current capacity unchanged. The blessed idiom is vec.swap(std::vector<T>());
c++11 added shrink_to_fit which is a non binding request to reduce capacity.