for_each中用lambda表达式遍历时,出错,,请各位指教
#include <iostream>#include <map>
#include <algorithm>
using namespace std;
int main()
{
map<int ,string> m;
m.insert(pair<int,string>(1,"a"));
m.insert(pair<int,string>(2,"c"));
m.insert(pair<int,string>(3,"d"));
m.insert(pair<int,string>(4,"e"));
m.insert(pair<int,string>(5,"f"));
m.insert(make_pair(6,"g"));
m.insert(map<int,string>::value_type (7,"h"));
m.insert(pair<int,string>(8,"i"));
for_each(m.begin(),m.end(),[](map<int,string>::iterator it)
{
cout<<it->second;
});
return 0;
}
错误信息如下