News for hackers. Stuff that matters.
Re:Vec<T> by arka2147483647 on Thursday October 09, 2025 @10:50AM (#45528512)
https://en.cppreference.com/w/cpp/container/vector/reserve.h...

says

> Increase the capacity of the vector (the total number of elements that the vector can hold without requiring reallocation) to a value that's greater or equal to new_cap.

I belive that the behaviour of reserve() is implementation defined.

Re:Vec<T> by tialaramex on Thursday October 09, 2025 @11:06AM (#45528747)
Because there's only a single function here, it has to either be Vec::reserve or Vec::reserve_exact

If you don't offer Vec::reserve_exact then people who needed that run out of RAM and will dub your stdlib garbage. If you don't offer Vec::reserve as we've seen C++ programmers will say "Skill issue" whenever a noob gets awful performance as a result. So, it's an easy choice.

Re:Vec<T> by mandarax8 on Thursday October 09, 2025 @11:05AM (#45528728)
That said MSVC,GCC and clang all implement it to allocate an exact value.