[v3] C++11 allocator reqs for vector in debug & profile mode
François Dumont
frs.dumont@gmail.com
Tue Nov 15 20:08:00 GMT 2011
On 11/14/2011 10:15 PM, Jonathan Wakely wrote:
> On 14 November 2011 20:15, François Dumont wrote:
>> I wonder if playing with allocator propagation in such a context is
>> right. The Standard define shrink_to_fit as a member method and not as a
>> global function. People implementing an allocator might not expect
>> allocators to be copy or anything else when calling vector::shrink_to_fit
>> which can normally be implemented without it.
> I don't see what being a member function or global function has to do
> with anything.
>
> Allocators must be copyable, containers take a copy of an allocator,
> if copying them misbehaves then you're in big trouble, long before
> calling shrink_to_fit.
>
> Could you explain why you think the current code is a problem?
>
> My change ensures that the new storage is created with the same
> allocator, so whether propagate_on_container_swap is true or not, the
> container ends up with the same allocator it had originally (or a copy
> of it) and storage that can be freed by that allocator.
>
Just forget my remark, I finally see nothing wrong with this patch.
I was still thinking about your remark several weeks ago when I submit
the same patch. I though that you would have added checks on
propagations flags which you haven't so it is fine.
Sorry for the noise.
François
More information about the Libstdc++
mailing list