c++ std::for_each函数

 

template 
   Function for_each (InputIterator first, InputIterator last, Function fn);

Applies function fn to each of the elements in the range [first,last).

The behavior of this template function is equivalent to:

template
  Function for_each(InputIterator first, InputIterator last, Function fn)
{
  while (first!=last) {
    fn (*first);
    ++first;
  }
  return fn;      // or, since C++11: return move(fn);
}

http://www.cplusplus.com/reference/algorithm/for_each/

 

Ref:

https://en.cppreference.com/w/cpp/algorithm/for_each

https://blog.csdn.net/asd1230123dsa/article/details/83793583

你可能感兴趣的:(C++)