remove character from string on condition c 2b 2b

Solutions on MaxInterview for remove character from string on condition c 2b 2b by the best coders in the world

showing results for - "remove character from string on condition c 2b 2b"
Ella
24 Jun 2017
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());