Yes there is. See reserve method. He will ask that the vector capacity be at least sufficient to contain the number of elements sent as an argument. If you can foresee the upper bound on the number of elements that you want to keep in the vector, you can reserve this amount of space in your vector.
An example from the above link is
// vector::reserve
You will see that as additional elements are added to the vector foo its capacity increases, but in the second case, since it has already reserved 100 element spaces, the capacity changes only once.
Here is an example.
source share