2 ms·
> how std::vector just codifies the practice of dynamically sized arrays using realloc I haven't ever seen std::vector using in-place realloc when resizing. Th
by vardump 8y ago
> how std::vector just codifies the practice of dynamically sized arrays using realloc
I haven't ever seen std::vector using in-place realloc when resizing. The implementations I've seen simply always allocate a larger vector and copy the elements over.
Realloc tries to expand already allocated memory region if there's enough space immediately after current block. New allocation and copy is only done when this is not possible.