C++ examples for STL:Lambda
Using a Lambda to Print array Values
#include <algorithm> #include <array> #include <cstdint> #include <iostream> int main()//from w ww. java 2 s . co m { using MyArray = std::array<int, 5>; MyArray myArray{ 1, 2, 3, 4, 5 }; std::for_each(myArray.cbegin(), myArray.cend(), [](auto&& number) { std::cout << number << std::endl; }); return 0; }