加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – vector :: erase会减少vector :: capacity吗?

发布时间:2020-12-16 10:44:43 所属栏目:百科 来源:网络整理
导读:Cppreference只说: Removes specified elements from the container. 1) Removes the element at pos. 2) Removes the elements in the range [first; last). Invalidates iterators and references at or after the point of the erase,including the end(
Cppreference只说:

Removes specified elements from the container. 1) Removes the element
at pos. 2) Removes the elements in the range [first; last).

Invalidates iterators and references at or after the point of the
erase,including the end() iterator.

The iterator pos must be valid and dereferenceable. Thus the end()
iterator (which is valid,but is not dereferencable) cannot be used as
a value for pos.

The iterator first does not need to be dereferenceable if first==last:
erasing an empty range is a no-op.

解决方法

不一定没有.当读取C标准(并且cppreference代表标准非常好)时,如果没有明确提到某些内容,那么假设不需要这样的东西.

对于C标准库实现来说,这可能是次优的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读