Boost logo

Boost :

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
> resulting
> 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
> 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).

kind regards


Boost list run by bdawes at, gregod at, cpdaniel at, john at