我有一个非常简单的测试程序,它使用istringstreams从std :: string读取整数.代码是:
std::map<int, int> imap;
int idx, value;
std::string str("1 2 3 4 5 6 7 8");
istringstream is(str);
while(is >> idx >> imap[idx]){
cout << idx << " " << imap[idx] << endl;
}
cout << endl;
std::map<int, int>::iterator itr;
for(itr = imap.begin(); itr != imap.end(); itr++){
cout << itr->first << " " << itr->second << endl;
}
Run Code Online (Sandbox Code Playgroud)
当我在Solaris 10上运行它时,它会产生以下输出:
1 2
3 4
5 6
7 8
1 2
3 4
5 6
7 8
Run Code Online (Sandbox Code Playgroud)
但是,当我在CentOS 7下运行时,我得到: …