2 // http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
4 // Note that these functions trim the same arguments passed in, and do not
7 #ifndef __BARRY_TRIM_H__
8 #define __BARRY_TRIM_H__
14 namespace Barry
{ namespace Inplace
{
17 static inline std::string
<rim(std::string
&s
) {
18 s
.erase(s
.begin(), std::find_if(s
.begin(), s
.end(), std::not1(std::ptr_fun
<int, int>(std::isspace
))));
23 static inline std::string
&rtrim(std::string
&s
) {
24 s
.erase(std::find_if(s
.rbegin(), s
.rend(), std::not1(std::ptr_fun
<int, int>(std::isspace
))).base(), s
.end());
28 // trim from both ends
29 static inline std::string
&trim(std::string
&s
) {
30 return ltrim(rtrim(s
));
33 }} // namespace Barry::Inplace