diff options
author | Max Kellermann <max@musicpd.org> | 2020-04-24 16:00:05 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-04-24 16:02:36 +0200 |
commit | 02556ffce9f8249297da3c38275673b6f47159a1 (patch) | |
tree | 9dc214b00b8e86893c39617f408a0ce3b3292c7a /src/tag | |
parent | 18ca73481919aa635efc2df80aa414e7f7fdaab0 (diff) |
tag/Tag: use class DereferenceIterator
Diffstat (limited to 'src/tag')
-rw-r--r-- | src/tag/Tag.hxx | 47 |
1 files changed, 3 insertions, 44 deletions
diff --git a/src/tag/Tag.hxx b/src/tag/Tag.hxx index f51b5ffc2..12099721e 100644 --- a/src/tag/Tag.hxx +++ b/src/tag/Tag.hxx @@ -24,6 +24,7 @@ #include "Item.hxx" // IWYU pragma: export #include "Chrono.hxx" #include "util/Compiler.h" +#include "util/DereferenceIterator.hxx" #include <memory> #include <utility> @@ -151,50 +152,8 @@ struct Tag { gcc_pure gcc_returns_nonnull const char *GetSortValue(TagType type) const noexcept; - class const_iterator { - friend struct Tag; - const TagItem *const*cursor; - - constexpr const_iterator(const TagItem *const*_cursor) noexcept - :cursor(_cursor) {} - - public: - constexpr const TagItem &operator*() const noexcept { - return **cursor; - } - - constexpr const TagItem *operator->() const noexcept { - return *cursor; - } - - const_iterator &operator++() noexcept { - ++cursor; - return *this; - } - - const_iterator operator++(int) noexcept { - auto result = cursor++; - return const_iterator{result}; - } - - const_iterator &operator--() noexcept { - --cursor; - return *this; - } - - const_iterator operator--(int) noexcept { - auto result = cursor--; - return const_iterator{result}; - } - - constexpr bool operator==(const_iterator other) const noexcept { - return cursor == other.cursor; - } - - constexpr bool operator!=(const_iterator other) const noexcept { - return cursor != other.cursor; - } - }; + using const_iterator = DereferenceIterator<TagItem *const*, + const TagItem>; const_iterator begin() const noexcept { return const_iterator{items}; |