inline std::string_view trim( std::string_view str ){
	auto first = str.find_first_not_of( ' ' );
	auto last  = str.find_last_not_of(  ' ' );
	auto chars_removed = first + (str.size()-last-1);
	return str.substr( first, str.size() - chars_removed );
}
示例#2
0
文件: utility.cpp 项目: emlai/zenith
std::string_view trim(std::string_view str)
{
    str.remove_prefix(str.find_first_not_of(' '));
    str.remove_suffix(str.size() - (str.find_last_not_of(' ') + 1));
    return str;
}