diff options
| author | Martin Ridgers <[email protected]> | 2021-12-15 13:42:38 +0100 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2021-12-16 09:35:51 +0100 |
| commit | 33f709ea4e3c6452a4d307d158c88623f899edb4 (patch) | |
| tree | b1cee6976206699389f966b1618e1cec53ef62f9 /zencore/include | |
| parent | Copy/paste errors in MD5 from SHA1 (diff) | |
| download | zen-33f709ea4e3c6452a4d307d158c88623f899edb4.tar.xz zen-33f709ea4e3c6452a4d307d158c88623f899edb4.zip | |
Not all compilers support C++20's iterator string_view contructor
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/string.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/zencore/include/zencore/string.h b/zencore/include/zencore/string.h index df78b2757..dba6843cf 100644 --- a/zencore/include/zencore/string.h +++ b/zencore/include/zencore/string.h @@ -665,8 +665,8 @@ template<typename Fn> uint32_t ForEachStrTok(const std::string_view& Str, char Delim, Fn&& Func) { - auto It = Str.begin(); - auto End = Str.end(); + const char* It = Str.data(); + const char* End = It + Str.length(); uint32_t Count = 0; while (It != End) @@ -677,7 +677,7 @@ ForEachStrTok(const std::string_view& Str, char Delim, Fn&& Func) continue; } - std::string_view Remaining{It, End}; + std::string_view Remaining{It, size_t(ptrdiff_t(End - It))}; size_t Idx = Remaining.find(Delim, 0); if (Idx == std::string_view::npos) @@ -686,7 +686,7 @@ ForEachStrTok(const std::string_view& Str, char Delim, Fn&& Func) } Count++; - std::string_view Token{It, It + Idx}; + std::string_view Token{It, Idx}; if (!Func(Token)) { break; |