std::vector resize downward

前端 未结 4 1907
醉话见心
醉话见心 2020-12-01 10:34

The C++ standard seems to make no statement regarding side-effects on capacity by either resize(n), with n < size(), or clear().

4条回答
  •  渐次进展
    2020-12-01 10:51

    The capacity will never decrease. I'm not sure if the standard states this explicitly, but it is implied: iterators and references to vector's elements must not be invalidated by resize(n) if n < capacity().

提交回复
热议问题