MCPcopy Create free account
hub / github.com/bwapi/bwapi / trim_right

Function trim_right

bwapi/Util/Source/Util/StringUtil.h:40–49  ·  view source on GitHub ↗

Trims the right side of str, using pred to decide trimming (while true) cppcheck-suppress passedByValue

Source from the content-addressed store, hash-verified

38// Trims the right side of str, using pred to decide trimming (while true)
39// cppcheck-suppress passedByValue
40inline void trim_right(std::string& str, std::function<bool(char)> pred) {
41 auto it = str.rbegin();
42 auto it_end = str.rend();
43 // Skip last items while predicate gives true
44 while (it != it_end && pred(*it)) {
45 ++it; // reverse iterator goes back
46 }
47 // Drop from here till the end
48 str.erase(it.base(), str.end());
49}
50
51// Trims left and right side of str, using predicate to check if the character
52// stays (false) or will be trimmed (true)

Callers 1

trimFunction · 0.85

Calls 1

endMethod · 0.80

Tested by

no test coverage detected