fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. map<int,int> m;
  5.  
  6. void fun(int i)
  7. {
  8. if(i%2!=0) m.erase(i);
  9. }
  10.  
  11. int main() {
  12. for(int i=0;i<10;i++) m[i]=i;
  13.  
  14. auto cur = m.begin();
  15. while(cur != m.end())
  16. {
  17. auto it = cur++;
  18. cout << it->first << " ";
  19. fun(it->first);
  20.  
  21.  
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5540KB
stdin
Standard input is empty
stdout
0 1 2 3 4 5 6 7 8 9