utils: trim(): Take string_view

This commit is contained in:
Albert S. 2021-10-10 12:01:16 +02:00
parent 86ac86b83f
commit 9593429f95
2 ha cambiato i file con 2 aggiunte e 3 eliminazioni

Vedi File

@ -182,10 +182,9 @@ std::string utils::toISODate(time_t t)
return std::string{result};
}
std::string utils::trim(const std::string &str)
std::string utils::trim(std::string_view view)
{
std::string_view chars = " \t\n\r";
std::string_view view = str;
auto n = view.find_first_not_of(chars);
if(n != std::string_view::npos)
{

Vedi File

@ -93,7 +93,7 @@ template <class T> inline std::string toString(const T &v)
return std::string(v.begin(), v.end());
}
std::string trim(const std::string &str);
std::string trim(std::string_view view);
} // namespace utils
#endif