I'm looking at the implementation of vector on https://www.cs.odu.edu/~zeil/cs361/sum18/Public/vectorImpl/index.html.
Under 1.3.1, it shows:
if( theSize == theCapacity ) ➀
reserve( 2 * theCapacity + 1 ); ➁
I am wondering, why is it reserving 2 * theCapacity + 1 instead of 2 * theCapacity?
In std::vector, it just doubles the capacity when the size of the vector is equal to the capacity, and you're trying to perform an append operation. I don't quite understand the purpose of the +1 here.