diff --git a/base/string_utils.cpp b/base/string_utils.cpp index 226f87319b..0278d3ec46 100644 --- a/base/string_utils.cpp +++ b/base/string_utils.cpp @@ -226,7 +226,7 @@ void Trim(std::string_view & sv) if (beg != sv.end()) { auto const end = std::find_if(sv.crbegin(), sv.crend(), [](auto c) { return !std::isspace(c); }).base(); - sv = std::string_view(beg, std::distance(beg, end)); + sv = std::string_view(sv.data() + std::distance(sv.begin(), beg), std::distance(beg, end)); } else sv = {}; diff --git a/base/string_utils.hpp b/base/string_utils.hpp index 13467ec3e5..211fd930c5 100644 --- a/base/string_utils.hpp +++ b/base/string_utils.hpp @@ -514,9 +514,10 @@ namespace impl { template bool from_sv(std::string_view sv, T & t) { - auto const res = std::from_chars(sv.begin(), sv.end(), t); + auto const end = sv.data() + sv.size(); + auto const res = std::from_chars(sv.data(), end, t); return (res.ec != std::errc::invalid_argument && res.ec != std::errc::result_out_of_range && - res.ptr == sv.end()); + res.ptr == end); } } // namespace impl