vector中erase的返回值
时间: 2023-10-21 22:55:55 浏览: 107
在vector中,erase函数的返回值是指向被删除元素之后的元素的迭代器。如果删除的是最后一个元素,则返回end()迭代器。这意味着,如果你在循环中使用erase函数删除元素,并且需要更新迭代器,你应该将返回的迭代器赋值给循环变量,以便正确地迭代容器中的元素。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [vector::erase方法,返回值是更新后的容器的被删除元素的后一个元素的迭代器,如果需要指向删除元素的前面...](https://blog.csdn.net/qq_34581491/article/details/51487239)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [erase返回值指向删除元素的下一个元素](https://blog.csdn.net/weixin_42917994/article/details/104485124)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [【C++】map::erase 与 vector::erase 的返回值](https://blog.csdn.net/COFACTOR/article/details/106188715)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文