data_type&
operator[](const key_type& k)Returns a reference to the object that is associated with a particular key. If the map does not already contain such an object, operator[] inserts the default object data_type(). [3]
[3] Since operator[] might insert a new element into the map, it can't possibly be a const member function. Note that the definition of operator[] is extremely simple: m[k] is equivalent to (*((m.insert(value_type(k, data_type()))).first)).second. Strictly speaking, this member function is unnecessary: it exists only for convenience.
昨天遇到一个极其变态的问题,map的内容感觉被破坏了,今天早上逐段跟踪,发现[]读访问一个map造成了map的数据破坏,还是别的map。
以后还是小心点,就算从设计上来看,这个key应该是存在的,但是在多线程的环境下,还是添加一点find代码吧。