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

Function trim_left

bwapi/Util/Source/Util/StringUtil.h:27–36  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

25// Trims the left side of str, using predicate to decide trimming (while true)
26// cppcheck-suppress passedByValue
27inline 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

Callers 1

trimFunction · 0.85

Calls 2

beginMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected