diff --git a/src/util/IterableSplitString.hxx b/src/util/IterableSplitString.hxx index 2b02f06ac..9b9350ee9 100644 --- a/src/util/IterableSplitString.hxx +++ b/src/util/IterableSplitString.hxx @@ -29,6 +29,7 @@ #pragma once +#include "StringSplit.hxx" #include "StringView.hxx" #include @@ -43,40 +44,41 @@ */ template class BasicIterableSplitString { - typedef BasicStringView StringView; + using string_view = std::basic_string_view; + using value_type = typename string_view::value_type; - using value_type = typename StringView::value_type; + using StringView = BasicStringView; - StringView s; + string_view s; value_type separator; public: - constexpr BasicIterableSplitString(StringView _s, + constexpr BasicIterableSplitString(string_view _s, value_type _separator) noexcept :s(_s), separator(_separator) {} class Iterator final { friend class BasicIterableSplitString; - StringView current, rest; + string_view current, rest; value_type separator; - constexpr Iterator(StringView _s, + constexpr Iterator(string_view _s, value_type _separator) noexcept :rest(_s), separator(_separator) { Next(); } - constexpr Iterator(std::nullptr_t n) noexcept - :current(n), rest(n), separator(0) {} + constexpr Iterator(std::nullptr_t) noexcept + :current(), rest(), separator() {} constexpr void Next() noexcept { - if (rest == nullptr) - current = nullptr; + if (rest.data() == nullptr) + current = {}; else { - const auto [a, b] = rest.Split(separator); + const auto [a, b] = Split(rest, separator); current = a; rest = b; } @@ -91,7 +93,7 @@ public: } constexpr bool operator==(Iterator other) const noexcept { - return current.data == other.current.data; + return current.data() == other.current.data(); } constexpr bool operator!=(Iterator other) const noexcept { @@ -115,7 +117,7 @@ public: } constexpr const_iterator end() const noexcept { - return {nullptr}; + return nullptr; } };