diff --git a/BAN/BAN/StringView.cpp b/BAN/BAN/StringView.cpp index 1aaf070178..fe30698559 100644 --- a/BAN/BAN/StringView.cpp +++ b/BAN/BAN/StringView.cpp @@ -61,7 +61,7 @@ namespace BAN return result; } - ErrorOr> StringView::split(char delim, bool allow_empties) + ErrorOr> StringView::split(char delim, bool allow_empties) const { size_type count = 0; { @@ -92,12 +92,12 @@ namespace BAN start = i + 1; } } - if (start != m_size) + if (start < m_size || (start == m_size && allow_empties)) TRY(result.push_back(this->substring(start))); return result; } - ErrorOr> StringView::split(bool(*comp)(char), bool allow_empties) + ErrorOr> StringView::split(bool(*comp)(char), bool allow_empties) const { size_type count = 0; { @@ -128,7 +128,7 @@ namespace BAN start = i + 1; } } - if (start != m_size) + if (start < m_size || (start == m_size && allow_empties)) TRY(result.push_back(this->substring(start))); return result; } diff --git a/BAN/include/BAN/StringView.h b/BAN/include/BAN/StringView.h index d7c6080ab7..68f61fbe4e 100644 --- a/BAN/include/BAN/StringView.h +++ b/BAN/include/BAN/StringView.h @@ -30,8 +30,8 @@ namespace BAN StringView substring(size_type, size_type = -1) const; - ErrorOr> split(char, bool = false); - ErrorOr> split(bool(*comp)(char), bool = false); + ErrorOr> split(char, bool = false) const; + ErrorOr> split(bool(*comp)(char), bool = false) const; char back() const; char front() const;