[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - include/o3tl

Stephan Bergmann sbergman at redhat.com
Thu Jan 21 00:19:10 PST 2016


 include/o3tl/enumarray.hxx |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

New commits:
commit 05752e5d4d0534fedc94febf68ce69ffdae717ff
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 19 10:46:13 2016 +0100

    Make enumarray_iterator adhere to iterator requirements
    
    ...or else using it with GCC 6 libstdc++ std::find causes compilation failures
    
    Change-Id: I95e674922348f72fab6da8f049b2b4fcbdc74d07
    (cherry picked from commit 96fea1a05d2cfb0173f292f59018c997d2f63c89)
    Reviewed-on: https://gerrit.libreoffice.org/21636
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/include/o3tl/enumarray.hxx b/include/o3tl/enumarray.hxx
index d4a3705..9b2f054 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


More information about the Libreoffice-commits mailing list