std::vector::clear (was: [GD-Windows] VS.net rants, was Re: VC++ lag)
Brought to you by:
vexxed72
From: Rich <leg...@xm...> - 2003-06-13 15:21:20
|
In article <001d01c331b6$36c64c00$0100a8c0@r0x0rz>, "Neil Stewart" <ne...@r0...> writes: > For some reason, they have changed the functionality of vector::clear() to > actually deallocate memory, rather than simply doing erase(begin(), end()), > which leaves the memory allocated. It sounds to me like you were relying on an implementation dependency. My copy of "C++ Standard Library" by Josuttis just says that both of these will remove all the elements of the vector. AFAIK, the standard makes no requirements about allocation/deallocation behavior for these operations, but I would expect both to potentially deallocate memory when I delete the whole vector. If you want to clear the vector without changing its allocation, you should do vector::resize(0) IMO. -- "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> |