fork(1) download
  1. #include <vector>
  2. #include <stdio.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. vector<int> stuff = {1,2,3,4,5};
  8. for(auto & n:stuff)
  9. {
  10. if ( n==3 || n == 4)
  11. {
  12. stuff.erase( stuff.begin() + (&n-stuff.data()) );
  13. }
  14. }
  15. for(auto &n:stuff)
  16. {
  17. printf("%d",n);
  18. }
  19.  
  20. }
Success #stdin #stdout 0s 4472KB
stdin
Standard input is empty
stdout
1245