std::map插入已存在的key时,key对应的内容不会被更新

std::map插入已存在的key时,key对应的内容不会被更新,如果不知道这一点,可能会造成运行结果与预期的不一致

 

“Because element keys in a map are unique, the insertion operation checks whether each inserted element has a key equivalent to the one of an element already in the container, and if so, the element is not inserted, returning an iterator to this existing element (if the function returns a value).”

http://www.cplusplus.com/reference/map/map/insert/

posted @ 2014-08-19 09:29  onemuji  阅读(2856)  评论(0编辑  收藏  举报