[libcxx-commits] [libcxx] [libc++][safety] Enhance exception safety for vector assignments in reallocation scenarios (PR #117516)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 26 08:43:32 PST 2024


philnik777 wrote:

I'm really not convinced that this is "without extra overhead" as you say. We still hold on to the old resources we don't actually need anymore, which may result in significant overhead, especially when the same allocation could be re-used (e.g. a free-list allocator that allocates at least 16 bytes, but the vector grows just from 4 bytes to 16 bytes). OTOH we don't actually have improved guarantees, since this improves only the reallocating scenario. If someone actually cares to have a strong exception guarantee (which seems to be almost no one given that we had some exception bugs in vector for over a year without anybody complaining), they can instead construct a new vector and swap it with the one they want to assign to.

https://github.com/llvm/llvm-project/pull/117516


More information about the libcxx-commits mailing list