fork download
  1. #include <iostream> // std::cout
  2. using namespace std;
  3. #include <functional> // std::not1
  4. #include <algorithm> // std::count_if
  5. #include <vector>
  6.  
  7. int main () {
  8. vector<int> sv = {3, 5, 10,12 };
  9. vector<int> v = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
  10. auto validSelection = [&](auto& e) {
  11. auto isSelected = [&] (auto& sve) {
  12. return e == sve;
  13. };
  14. return find_if(sv.begin(), sv.end(), isSelected) != sv.end();
  15. };
  16. stable_partition(v.begin(), next(v.begin(),8) , not1(function<bool(int&)>(validSelection)));
  17. for (int n : v) {
  18. std::cout << n << ' ';
  19. }
  20. std::cout << '\n';
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 4556KB
stdin
Standard input is empty
stdout
1 2 4 6 7 8 3 5 9 10 11 12 13 14 15