fork(19) download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <iterator>
  6.  
  7. int main()
  8. {
  9. std::vector<int> v1;
  10. for (int i = 0; i < 100; i++) v1.push_back(i);
  11.  
  12. std::vector<int> v2;
  13. std::vector<int> v3;
  14.  
  15. bool toggle = false;
  16. std::partition_copy(v1.begin(),
  17. v1.end(),
  18. std::back_inserter(v2),
  19. std::back_inserter(v3),
  20. [&toggle](int) { return toggle = !toggle; });
  21.  
  22. std::cout << v2.size() << "\n";
  23. std::cout << v3.size() << "\n";
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 3060KB
stdin
Standard input is empty
stdout
50
50