| 191 | // Removes all occurrences of given character from string |
| 192 | template <typename TStringType> |
| 193 | void RemoveAll(TStringType& str, typename TStringType::char_type ch) { |
| 194 | size_t pos = str.find(ch); // 'find' to avoid cloning of string in 'TString.begin()' |
| 195 | if (pos == TStringType::npos) { |
| 196 | return; |
| 197 | } |
| 198 | |
| 199 | typename TStringType::iterator begin = str.begin(); |
| 200 | typename TStringType::iterator end = begin + str.length(); |
| 201 | typename TStringType::iterator it = std::remove(begin + pos, end, ch); |
| 202 | str.erase(it, end); |
| 203 | } |