在看C++ primer的lambda时,看到for_each时,有点懵,所以简答记录一下
for_each()事实上是個function template,其实质如下[effective STL item 41]
template<typename InputIterator, typename Function>
Function for_each(InputIterator beg, InputIterator end, Function f) {
while(beg != end)
f(*beg++);
}
理解了这个再回去看lambdad的例子也就好理解了