Excuse me for the badly-formatted question, to give context , i'm trying to re-implement vector container and following this quote from the reference:
... vector containers may allocate some extra storage to accommodate for possible growth, and thus the container may have an actual capacity greater than the storage strictly needed to contain its elements (i.e., its size). Libraries can implement different strategies for growth to balance between memory usage and reallocations...
and this question i understand that most implementations use some sort of little formula N*K
where N
stands for it's size and K
for the growth ratio, the golden ratio used by most implementations is 1.5
according to the answers, however concluding from the reference it seems it gives absolute freedom regarding the growth strategy but doesn't mention where or when this allocation of N*K
should happen, in which constructors if there's any or in which member methods, maybe it gives freedom too regarding this aspect, well if that's the case is there a recommended map by which one should guide.