Merge pull request #6367 from danpls/fix-npos

tokenizeString: Fix semantic mistake
This commit is contained in:
Eelco Dolstra 2022-04-05 23:19:35 +02:00 committed by GitHub
commit f89fa29914
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1259,9 +1259,9 @@ template<class C> C tokenizeString(std::string_view s, std::string_view separato
{ {
C result; C result;
auto pos = s.find_first_not_of(separators, 0); auto pos = s.find_first_not_of(separators, 0);
while (pos != std::string::npos) { while (pos != std::string_view::npos) {
auto end = s.find_first_of(separators, pos + 1); auto end = s.find_first_of(separators, pos + 1);
if (end == std::string::npos) end = s.size(); if (end == std::string_view::npos) end = s.size();
result.insert(result.end(), std::string(s, pos, end - pos)); result.insert(result.end(), std::string(s, pos, end - pos));
pos = s.find_first_not_of(separators, end); pos = s.find_first_not_of(separators, end);
} }