返回信息流看了一晚上lambda表达式,还是没太搞明白。
像这样,for_each中的函数对象,怎么改成lambda表达式呢?
struct output
{
void operator() (pair<string, int> it)
{
cout << it.second << endl;
}
};
for_each(month.begin(), month.end(), output());
感觉lambda表达式真的很好用,在STL中完全取代函数对象应该没问题。
这是一条镜像帖。来源:北邮人论坛 / cpp / #72277同步于 2013/7/2
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
[问题]lambda表达式
amarantine
2013/7/2镜像同步3 回复
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
懂了!谢啦。
【 在 gsl2011 的大作中提到: 】
: [](pair string int it){cout it.second endl}
: 拿手机写的,勿怪。