I\'m currently using the following code to right-trim all the std::strings in my programs:
std::strings
std::string s; s.erase(s.find_last_not_of(\" \\n\\r\\
Trim C++11 implementation:
static void trim(std::string &s) { s.erase(s.begin(), std::find_if_not(s.begin(), s.end(), [](char c){ return std::isspace(c); })); s.erase(std::find_if_not(s.rbegin(), s.rend(), [](char c){ return std::isspace(c); }).base(), s.end()); }