Trims the left side of str, using predicate to decide trimming (while true) cppcheck-suppress passedByValue
| 25 | // Trims the left side of str, using predicate to decide trimming (while true) |
| 26 | // cppcheck-suppress passedByValue |
| 27 | inline void trim_left(std::string& str, std::function<bool(char)> pred) { |
| 28 | auto it = str.begin(); |
| 29 | auto it_end = str.end(); |
| 30 | // Skip first items while predicate gives true |
| 31 | while (it != it_end && pred(*it)) { |
| 32 | ++it; |
| 33 | } |
| 34 | // Drop from the beginning to here |
| 35 | str.erase(str.begin(), it); |
| 36 | } |
| 37 | |
| 38 | // Trims the right side of str, using pred to decide trimming (while true) |
| 39 | // cppcheck-suppress passedByValue |