---
title: "关于std map的插入和删除"
author: "calmhawk"
date: "2013-01-17T11:41:44Z"
tags: []
categories: ["编程语言"]
slug: "std-map"
draft: false
lastmod: "2013-01-17T11:41:44Z"
id: 1771389
url: "https://calmhawk.iteye.com/blog/1771389"
---

关于代码里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.