版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/how0723/article/details/80934487
#include <iostream>
#include <algorithm>
int main()
{
int intArr[] = { 1, 2, 3, 4, 5 };
std::cout << "std::for_each ......" << std::endl;
std::for_each(std::begin(intArr), std::end(intArr),
[](int i)->void{ std::cout << i << std::endl; });
std::cout << "for(const auto& i : intArr) ......" << std::endl;
for(const auto& i : intArr)
std::cout << i << std::endl;
return 0;
}