Re: std::vector::clear (was: [GD-Windows] VS.net rants, was Re: VC++ lag)
Brought to you by:
vexxed72
From: Rich <leg...@xm...> - 2003-06-16 18:05:34
|
In article <005e01c33214$9c9b8b40$0100a8c0@r0x0rz>, "Neil Stewart" <ne...@r0...> writes: > 2. While the standard does not appear to say that erase() must not > deallocate memory, it very explicitly states that insert() will allocate > memory if required, and it is also very clear that resize() and reserve() > should never reduce capacity() (i.e. deallocate memory). 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. -- "The Direct3D Graphics Pipeline"-- code samples, sample chapter, FAQ: <http://www.xmission.com/~legalize/book/> izfree: Open source tools for Windows Installer <http://izfree.sourceforge.net> |