During the proceedings of this question, it came to light that there appear to be no time complexity requirements placed on std::vector<T>::clear by the C++ standard.

Table 100 under 23.2.3 says:

Destroys all elements in a. Invalidates all references, pointers, and iterators referring to the elements of a and may invalidate the past-the-end iterator. post: a.empty() returns true

And... that's it. There's no entry for it specifically under 23.3.6, and no explicit indication that the following applies to clear:

[C++11: 23.3.6.1/1]: A vector is a sequence container that supports random access iterators. In addition, it supports (amortized) constant time insert and erase operations at the end; insert and erase in the middle take linear time. Storage management is handled automatically, though hints can be given to improve efficiency. [..]

So... is this really true? Or have I simply missed it?

Edit
Report