Accessing member variables through boost lambda placeholder

…衆ロ難τιáo~ 提交于 2019-12-04 12:35:08

std::map will add const to its key; this is to prevent messing up the ordering. Your pair should be:

std::pair<const int, int>

Like dirkgently suggests, use the value_type to always get the correct type. The verbosity is alleviated with a typedef:

typedef std::map<int, int> int_map;

int_map::value_type::second

Try:

for_each(theMap.begin(), theMap.end(), 
         cout << bind(&map<int, int>::value_type::second, _1) << constant(" "));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!