From d89745ca21ffc916f921d79282c671aa080fd32f Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Sun, 20 Nov 2022 06:59:54 +0100 Subject: [PATCH] Implement iterator_traits in ENUM_ITERATOR --- include/enum_vector.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/enum_vector.h b/include/enum_vector.h index 386eb7df63..62da55df00 100644 --- a/include/enum_vector.h +++ b/include/enum_vector.h @@ -21,6 +21,7 @@ #ifndef ENUM_VECTOR_H #define ENUM_VECTOR_H +#include #include /** @@ -74,6 +75,12 @@ class ENUM_ITERATOR int val; public: + using value_type = T; + using difference_type = std::ptrdiff_t; + using pointer = T*; + using reference = T&; + using iterator_category = std::input_iterator_tag; + ENUM_ITERATOR( const T& f ) : val( static_cast( f ) ) {} ENUM_ITERATOR() : val( static_cast( beginVal ) ) {} ENUM_ITERATOR operator++() @@ -85,6 +92,7 @@ public: T operator*() { return static_cast( val ); } ENUM_ITERATOR begin() { return *this; } ENUM_ITERATOR end() { return ENUM_ITERATOR( endVal ); } + bool operator==( const ENUM_ITERATOR& aIt ) { return val == aIt.val; } bool operator!=( const ENUM_ITERATOR& aIt ) { return val != aIt.val; } };