3 ms·
https://en.cppreference.com/w/cpp/container/vector/reserve.html https://en.cppreference.com/w/cpp/container/vector/reserve.h... says > Increase the capacity o
by arka2147483647 1y ago
https://en.cppreference.com/w/cpp/container/vector/reserve.html 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.
- tialaramex 1y agoBecause 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.
- mandarax8 1y agoThat said MSVC,GCC and clang all implement it to allocate an exact value.