关于std 地图的插入和删除
关于std map的插入和删除
关于代码里map的删除,有一点困惑:
在删除前用iterator保存位置,对map进行插入或删除后,iterator是否有效.
看完标准后释然,直接上标准:
23.1.2.8:The insert members shall not affect the validity of iterators and references to the container, and the erase members shall invalidate only iterators and references to the erased elements.