News for hackers. Stuff that matters.
Re:A brief introduction to C++'s model for type- and resourc... by hellofunk on Friday January 15, 2016 @09:38AM (#10909524)
Good points, I hadn't considered that the implementation of a vector could widely vary. That makes sense.
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.
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.
Re:A brief introduction to C++'s model for type- and resourc... by hellofunk on Friday January 15, 2016 @01:39PM (#10911159)
That is rather interesting!