an example of using C++ STL for_each with lambda


👍 g++ -std=c++11 two_iterators.cpp
👍 ./a.out
1 2 
👍 cat two_iterators.cpp 
#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<int> d = {1,2,3,4,5};
  auto it1 = d.begin();
  auto it2 = it1 + 2;
  for_each(it1, it2, [](int el) {
    cout << el << ' ';
  });
  cout << endl;
}