I understand that the complexity of the clear() operation is linear in the size of the container, because the destructors must be called. But what about primitive types (and
gcc's version of std::_Destroy, which is what is eventually used by clear(), tries to template on on whether the type has a trivial destructor, so in that case the complexity is constant even without an optimisation pass. However I don't know how well the template works.