fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <list>
  5. using namespace std;
  6.  
  7. int main() {
  8. list<string> l = {"aab", "aac", "abb", "123", "aaw", "wws"};
  9. list<string> whiteList = {"aa", "ab"};
  10. auto end = remove_if(l.begin(), l.end(), [&whiteList](string item)
  11. {
  12. for(auto &s : whiteList)
  13. {
  14. auto res = std::mismatch(s.begin(), s.end(), item.begin());
  15. if (res.first == s.end()){
  16. return false; //found allowed prefix
  17. }
  18. }
  19. return true;
  20. });
  21. for (auto it = l.begin(); it != end; ++it){
  22. cout<< *it << endl;
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
aab
aac
abb
aaw