1class IsChars
2{
3public:
4 IsChars(const char* charsToRemove) : chars(charsToRemove) {};
5
6 bool operator()(char c)
7 {
8 for(const char* testChar = chars; *testChar != 0; ++testChar)
9 {
10 if(*testChar == c) { return true; }
11 }
12 return false;
13 }
14
15private:
16 const char* chars;
17};
18auto chars_to_remove = "()- ";
19str.erase(std::remove_if(str.begin(), str.end(), IsChars(chars_to_remove)), str.end());