STL中map使用问题
最近在学STL,在map和multimap部分遇到一个问题,使用insert(interator _Where,const value_type& _Val)之后,发现输出的结果并不是自己所期望的,请高手指教:
#include <map>
#include <iostream>
using namespace std;
int main()
{
map <int,int>::iterator m1_pIter;
map <int,int> m1;
typedef pair <int,int> Int_Pair;
m1.insert(Int_Pair(1,10));
m1.insert(Int_Pair(2,20));
m1.insert(Int_Pair(3,30));
m1.insert(Int_Pair(4,40));
m1_pIter=m1.begin();
m1_pIter++;
m1.insert(m1_pIter,Int_Pair(5,50));
cout<<"The Key values of m1 is:";
for(m1_pIter=m1.begin();m1_pIter!=m1.end();m1_pIter++){
cout<<m1_pIter->first;
}
}
结果为The Key values of m1 is:12345,而我觉得应该是The Key values of m1 is:15234;
(使用minGW G++编译)