summaryrefslogtreecommitdiff
path: root/AK/StringView.h
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-09-06 21:14:08 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-08 14:01:21 +0200
commit1b3ecb01a5c6e5fd01e40b60f253ab8ecef0b970 (patch)
tree376f40ce61328c9a937d5046f7e47e7ad0bfe63e /AK/StringView.h
parent9648bf4ada00801ceada7f48248e0d9ab598b227 (diff)
downloadserenity-1b3ecb01a5c6e5fd01e40b60f253ab8ecef0b970.zip
AK: Add generic SimpleIterator class to replace VectorIterator.
Diffstat (limited to 'AK/StringView.h')
-rw-r--r--AK/StringView.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/AK/StringView.h b/AK/StringView.h
index a1d4de9cbb..9a03fd9bc8 100644
--- a/AK/StringView.h
+++ b/AK/StringView.h
@@ -37,8 +37,6 @@ namespace AK {
class StringView {
public:
- using ConstIterator = const char*;
-
ALWAYS_INLINE constexpr StringView() { }
ALWAYS_INLINE constexpr StringView(const char* characters, size_t length)
: m_characters(characters)
@@ -77,8 +75,10 @@ public:
const char& operator[](size_t index) const { return m_characters[index]; }
- ConstIterator begin() const { return characters_without_null_termination(); }
- ConstIterator end() const { return begin() + length(); }
+ using ConstIterator = SimpleIterator<const StringView, const char>;
+
+ constexpr ConstIterator begin() const { return ConstIterator::begin(*this); }
+ constexpr ConstIterator end() const { return ConstIterator::end(*this); }
unsigned hash() const;