159 |
} |
} |
160 |
} |
} |
161 |
|
|
162 |
template <class Ch> |
template <class Str> |
163 |
std::basic_string<Ch> trim(const basic_string<Ch>& str) |
Str trim(const Str& str) |
164 |
{ |
{ |
165 |
if (str.size() == 0) |
if (str.size() == 0) |
166 |
return str; |
return str; |
167 |
std::basic_string<Ch>::size_type b = str.find_first_not_of(" \t\n\r"); |
typename Str::size_type b = str.find_first_not_of(" \t\n\r"); |
168 |
std::basic_string<Ch>::size_type e = str.find_last_not_of(" \t\n\r"); |
typename Str::size_type e = str.find_last_not_of(" \t\n\r"); |
169 |
if (b == std::basic_string<Ch>::npos) |
if (b == Str::npos) |
170 |
return ""; |
return ""; |
171 |
return basic_string<Ch>(str, b, e-b+1); |
return Str(str, b, e-b+1); |
172 |
} |
} |
173 |
|
|
174 |
} |
} |