Boost logo

Boost :

Subject: Re: [boost] [review] The review of Boost.DoubleEnded starts today: September 21 - September 30
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2017-10-11 19:00:05

On 11/10/2017 13:20, Thorsten Ottosen via Boost wrote:

> why? If the vector is full, capacity() == size(). If the devector's
> right hand size is full, size() == back_capacity().

But if capacity() is an alias for back_capacity() and size() ==
capacity(), an insertion in the middle would not trigger a reallocation.
capacity() > size() means to me "is there room for a new insertion
without reallocation"?

>> capacity == size means that any insertion will lead to reallocation.
> That's the alternative, but that is the one that breaks generic code,
> isn't it?.

Which generic code? I think it's the opposite.

> With my scheme above, if you absolutely must know if insertion
> reallocates, you can use front_free_capacity() + back_free_capacity() ==
> 0. I don't know if that needs a special function though (it could be
> called full() ).

For any container with reserve/capacity (vector, string, flat_map,
circular_buffer, poly_collection, etc.) if capacity() == size() that
means a reallocation will happen for *any* insertion, not just
push_back. If you want guarantees for back insertion only, then
back_capacity() should give you the answer. Just my 2 cents.



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