pull/14/head
Tom Early 5 years ago
parent 110a70a27a
commit 08e5bc7e3e

@ -5,19 +5,13 @@
// trim from start (in place) // trim from start (in place)
static inline void ltrim(std::string &s) static inline void ltrim(std::string &s)
{ {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { return !std::isspace(ch); }));
{
return !std::isspace(ch);
}));
} }
// trim from end (in place) // trim from end (in place)
static inline void rtrim(std::string &s) static inline void rtrim(std::string &s)
{ {
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !std::isspace(ch); }).base(), s.end());
{
return !std::isspace(ch);
}).base(), s.end());
} }
// trim from both ends (in place) // trim from both ends (in place)

Loading…
Cancel
Save

Powered by TurnKey Linux.