4 ms·
So for std::vector you avoid the "generic way" and specify the size up front or when needed with reserve. Just as efficient as a realloc in C. Many things can
by rleigh 10y ago
So for std::vector you avoid the "generic way" and specify the size up front or when needed with reserve. Just as efficient as a realloc in C. Many things can be inefficient or wasteful, but vector allocation and resizing isn't one of them if you care to use it effectively.