fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main() {
  6. const auto foo = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  7. auto bar = cbegin(foo);
  8.  
  9. for (auto it = bar + 3; it < cend(foo); bar = it, it = bar + 3) {
  10. for_each(bar, it, [](const auto& i) { cout << i << endl; });
  11. }
  12.  
  13. for_each(bar, cend(foo), [](const auto& i) { cout << i << endl; });
  14. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
1
2
3
4
5
6
7
8
9
10