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?
That is what you are doing.
resizefills the new space with value-initialized elements, so there are no "empty places". It seems like you need to callstd::vector::reserveinstead.