C++ examples for STL Algorithm:for_each
Calling a Function on Every Element in a Container with for_each algorithm
#include <algorithm> #include <cinttypes> #include <iostream> #include <vector> using namespace std; int main(int argc, char* argv[]) { vector<int32_t> myVector {1,2,3,4,5}; for_each(myVector.begin(), myVector.end(), [](int32_t value) {//from ww w . j a va 2 s . c o m cout << value << endl; }); return 0; }