fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4.  
  5. int main()
  6. {
  7. std::vector <int> v = { 1, 5, 2, 5, 5, 5};
  8.  
  9. std::for_each(v.begin(), v.end(),
  10.  
  11. [](int i) {
  12. if (i == 5)
  13. return;
  14. std::cout << i << std::endl; });
  15. }
  16.  
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
1
2