Re: std::vector::clear (was: [GD-Windows] VS.net rants, was Re: VC++ lag)
Brought to you by:
vexxed72
From: Neil S. <ne...@r0...> - 2003-06-16 21:14:18
|
> Right. This is why I was saying you should do resize(0) if you want > to retain the memory. I'm not a C++ language lawyer, but resize(0) > more explicitly tells me as a reader of the code that they wanted to > retain the current allocation but forget all the elements. clear() to > me says that its OK to delete the current allocation as well as forget > all the elements. Well, if you have followed the last few messages on this subject, you will be aware that doing resize(0) is also no use (in terms of avoiding allocation & deallocation), as there is nothing in the standard that says that the implementor cannot realocate the memory elsewhere, so long as capacity() is greater or equal to what it was previously. You might say that it's illogical for them to do that, but I would have said that (and still *do* say that) about making clear() deallocate, and I'm far from the only one. Oh, and they can format drive C while they're at it. ;) So write your own, boys and girls, because the lunatics took over the asylum. - Neil. |