Does std::vector.pop_back() change vector's capacity?

后端 未结 6 1538
情深已故
情深已故 2020-12-09 11:04

If I allocated an std::vector to a certain size and capacity using resize() and reserve() at the beginning of my program, is it possible that

6条回答
  •  独厮守ぢ
    2020-12-09 11:48

    NO. Same as push_back , pop_back won't impact the capacity(). They just impact the size().

    EDIT:

    I should have said push_back won't change the capacity when the v.size() < v.capacity().

提交回复
热议问题