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

后端 未结 6 1537
情深已故
情深已故 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:45

    No. pop_back() will not shrink the capacity of vector. use std::vector(v).swap(v) instead.

提交回复
热议问题