diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/ListIterator.h | 13 | ||||
-rw-r--r-- | backend/ListIterator.hpp | 5 |
2 files changed, 17 insertions, 1 deletions
diff --git a/backend/ListIterator.h b/backend/ListIterator.h index 3d11806..cf14724 100644 --- a/backend/ListIterator.h +++ b/backend/ListIterator.h @@ -2,6 +2,8 @@ #include "backend/List.h" +#include <iterator> + #include <stddef.h> template <typename T> @@ -10,12 +12,21 @@ class List; template <typename T> class ListIterator { public: + // required for <algorithm> compatibility + using iterator_category = std::forward_iterator_tag; + using value_type = T; + using difference_type = std::ptrdiff_t; + using pointer = T*; + using reference = T&; + +public: ListIterator(ListLink<T> * & here); public: T & operator * () const; - ListIterator<T> & operator ++ (); bool operator != (const ListIterator<T> &) const; + ListIterator<T> & operator ++ (); + bool operator ! () const; private: ListLink<T> * here = nullptr; diff --git a/backend/ListIterator.hpp b/backend/ListIterator.hpp index 30a556f..45f9acc 100644 --- a/backend/ListIterator.hpp +++ b/backend/ListIterator.hpp @@ -45,3 +45,8 @@ bool ListIterator<T>::operator != (const ListIterator<T> & rhs) const { return this->here != nullptr; } +template <typename T> +bool ListIterator<T>::operator ! () const { + return this->here == nullptr; +} + |