El 17/10/2017 a las 15:25, Thorsten Ottosen via Boost escribió:
Den 17-10-2017 kl. 14:23 skrev Joaquin M López Muñoz via Boost:
This is the tradeoff. I guess your reservation stems from the desire that capacity()-size() indicates the number of insertions before reallocation, to that I just answered Ion in another post. My (current) opinion is that capacity() should not be provided.
My reservation is not really with capacity(), but with the cost of allocation for small flat containers. Last I checked, you could copy hundreds of objects for the price of one allocation (and the deallocation that is implied).
If your concern is allocation cost and you do not worry that much about wasted space, you can increase the growing factor G to lower that (amortized) cost down at the expense of increasing the average free space not used on on one of both sides when the other side gets exhausted. Joaquín M López Muñoz