News for hackers. Stuff that matters.
Re:A brief introduction to C++'s model for type- and resourc... by plq on Friday January 15, 2016 @08:03AM (#10909022)
std::vector spec leaves quite a bit of performance-critical details unspecified. I imagine the allocator behaviour differs enough between implementations that they implemented their own to keep performance in different platforms more predictable. The performance requirements for a physics engine can be quite different from the general case that the std::vector spec is aiming for.

I imagine templates are frowned upon for the same reason -- too many moving parts. Otherwise they're perfectly fine to use in projects that have goals other than portably predictable performance.

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!