Possible Duplicate:
What is the complexity of std::vector<T>::clear() when T is a primitive type?
If I have a std::vector
with a primitive type, and I call clear()
(this way push_back
starts at the beginning of the capacity
), is the clear()
call going to be completed in constant time or linear time? The documentation says it destroys all the elements, but if the element is an int, there shouldn't be anything to destroy, right?
edit: I found a duplicate that has a poster who explains in detail that the implementation can check whether the destructor is trivial, and gives an example of one compiler that has that check (GCC).
What is the complexity of std::vector<T>::clear() when T is a primitive type?