Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <algorithm>
- using namespace std;
- int main(){
- set<int> a{1,2,3,4,5,6,7,8};
- /*
- remove_if(a.begin(),a.end(),[](int val){return val%2 == 0;});
- a.begin() - iterator to const node_type, then *a.begin() = 10 isn't valid, so
- remove_if can't be applied there;
- */
- set<int> filtered;
- copy_if(a.begin(),a.end(), inserter(filtered, filtered.end()),[](int val){return val%2 == 0;});
- for(const auto& v: filtered)
- cout << v << ' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement