Subject: Re: [boost] [devector] optimum growing/insertion policy
From: Thorsten Ottosen (tottosen_at_[hidden])
Date: 2017-10-17 13:25:19
Den 17-10-2017 kl. 14:23 skrev Joaquin M LÃ³pez MuÃ±oz via Boost:
> El 16/10/2017 a las 10:45, Thorsten Ottosen via Boost escribiÃ³:
>>>> I think in the case where the user has called reserve, itâs a little
>>>> problematic that insert may allocate anyway. That is, for many uses
>>>> there is
>>>> no infinitely growing sequence .
>> And this one? I'm still not sure we want to allocate on insert before
>> the buffer is full.
> If we must guarantee that the buffer is full before reallocation, the
> policy won't be optimal wrt number of movements.
Correct. If you want that for insert, you would need to allocate twice
the needed space.
> This is the tradeoff. I
> 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).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk