#include <algorithm>
#include <string_view>
#include <string>
constexpr std::string_view trim(std::string_view s) noexcept{
using namespace std::literals::string_literals;
constexpr auto white_spaces { "\f\n\r\v\t "sv };
auto first { s.find_first_not_of(white_spaces) };
auto last { s.find_last_not_of(white_spaces) + 1 };
return s.substr(first, last);
}
【简单的trim函数实现 | C++ 17】
最新推荐文章于 2024-05-20 15:29:54 发布