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-14 19:49:16
|
> Is there a particular part of the standard that clearly says that clear > *must be implemented* as erase(begin(), end())? It's at section 23.1.1 [lib.sequence.reqmts], and it clearly shows this as a requirement for sequences, which therefore covers vector. > Moreover, the point of standards (especially the C++ standard) is as > much what they say and what they *do not* say. Your argument that > since it doesn't explicitly say clear() deallocates means that it should > not is wrong. There is a clear language in the standard of phrases > like "should have" and "must have" and such that have well defined > meanings. Lack of specification is exactly that - something the > standard fails to specify. Sorry, but this is nonsense. You are suggesting that anything the standard does not forbid explicitly is "fair game". The standard does not specify that, under no circumstances, should vector::push_back() format drive C. Are you suggesting that an implementation should therefore be allowed to interpret this as a legal implementation detail? What happens is that people read meanings into things which are not really there in order to support their own arguments, so common sense has to prevail at some point. In this case, common sense settled on "no deallocation" quite some time ago, and then someone came along and threw that in the bin because it didn't suit their own requirements. > A similar argument used to occur with list<>::size() being O(N) on > one implementation and O(1) on just about nearly every other > implementation. Doesn't surprise me. What was the outcome of this one? > Luckily the next round of C++ standards (probably around 2020 at > the current pace) should clearly define more implementation > requirements of the STL, but I still doubt they will define allocation > deallocation requirements. I find it sad that the next standard is likely to be an order of magnitude more complex, not due to new content, but mainly due to tightening up of the language used to stop people taking liberties where it is pretty clear what was meant in the first place. - Neil. |