What is the complexity of std::vector<T>::clear() when T is a primitive type?
问题 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 POD)? It seems the best thing to do would be to set the vector size to 0, so that the complexity is constant. If this is possible, is it also possible for std::unordered_map? 回答1: It seems the best thing to do would be to set the vector size to 0, so that the complexity is constant. In general, the complexity of resizing