fork(2) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. vector<int> foo = { 2, 1, 6, 1, 4, 6, 2, 1, 1 };
  9. auto last = end(foo);
  10.  
  11. for(auto first = begin(foo); first < last; ++first) last = remove(next(first), last, *first);
  12.  
  13. foo.erase(last, end(foo));
  14.  
  15. for(const auto& i : foo) cout << i << ' ';
  16. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
2 1 6 4