I know how much space I initially need in a std::vector
. So I use .resize()
to set the new vector to that size. But when using .push_back()
afterwards, it adds the elements at the end of the allocated size increasing it by one.
How can I add new elements automatically in the empty placed of a resized vector?