summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-01-19 10:46:13 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-01-19 10:46:13 +0100
commit96fea1a05d2cfb0173f292f59018c997d2f63c89 (patch)
treeb5b32a3b0f3aab6506724de781785e47ecb07d60 /include
parente96eaea07dde9a375c4d771c27ee7e7da9ef53b6 (diff)
Make enumarray_iterator adhere to iterator requirements
...or else using it with GCC 6 libstdc++ std::find causes compilation failures Change-Id: I95e674922348f72fab6da8f049b2b4fcbdc74d07
Diffstat (limited to 'include')
-rw-r--r--include/o3tl/enumarray.hxx10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/o3tl/enumarray.hxx b/include/o3tl/enumarray.hxx
index a6861c1b8202..c264c2f69615 100644
--- a/include/o3tl/enumarray.hxx
+++ b/include/o3tl/enumarray.hxx
@@ -22,6 +22,7 @@
#include <sal/config.h>
#include <iterator>
+#include <type_traits>
namespace o3tl {
@@ -86,7 +87,10 @@ public:
typedef typename EA::value_type value_type;
typedef typename EA::key_type key_type;
typedef std::bidirectional_iterator_tag iterator_category; //should be random access, but that would require define subtraction operators on the enums
- typedef typename EA::key_type difference_type;
+ typedef
+ typename std::make_signed<
+ typename std::underlying_type<typename EA::key_type>::type>::type
+ difference_type;
typedef typename EA::value_type* pointer;
typedef typename EA::value_type& reference;
@@ -95,8 +99,8 @@ public:
value_type &operator*() { return (*m_buf)[static_cast<key_type>(m_pos)]; }
value_type *operator->() { return &(operator*()); }
self_type &operator++() { ++m_pos; return *this; }
- bool operator!=(const self_type& other) { return m_buf != other.m_buf || m_pos != other.m_pos; }
- bool operator==(const self_type& other) { return m_buf == other.m_buf && m_pos == other.m_pos; }
+ bool operator!=(const self_type& other) const { return m_buf != other.m_buf || m_pos != other.m_pos; }
+ bool operator==(const self_type& other) const { return m_buf == other.m_buf && m_pos == other.m_pos; }
};
}; // namespace o3tl