include/o3tl/enumarray.hxx | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
New commits: commit af2ed6d5c9bf5495d7aa1036d35a86444a95d35a Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Mon Nov 25 17:05:45 2019 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Tue Nov 26 08:39:10 2019 +0100 Remove bogus enumarray[_const]_iterator assignment ops ...that write into the m_buf of reference type (or at least would try to if the assignment op were ever instantiated for enumarray_const_iterator). They have been present since a0032a2dc2e4ac7615baaacdde5fefa64048822e "improve o3tl::enumarray const-ness" turned m_buf from a pointer to a reference. (Found with recent Clang 10 trunk -Werror,-Wdeprecated-copy, cf. <https://gerrit.libreoffice.org/#/c/83698/> "Remove some redundantly user-declared copy ctors and assignment ops".) But then at least some MSVC 2017 would still want to implicitly define them as non-deleted (see <https://ci.libreoffice.org/job/gerrit_windows/50602/> trying to build a prior version of this change) and fail, so change m_buf from reference to pointer. Change-Id: I3d4a420d2c4c6a6e966df74cfa33b5e00e0af5f6 Reviewed-on: https://gerrit.libreoffice.org/83701 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/include/o3tl/enumarray.hxx b/include/o3tl/enumarray.hxx index ca012e197f27..a3c09d56bea0 100644 --- a/include/o3tl/enumarray.hxx +++ b/include/o3tl/enumarray.hxx @@ -85,7 +85,7 @@ public: template<typename EA> class enumarray_iterator { - EA& m_buf; + EA* m_buf; size_t m_pos; public: typedef enumarray_iterator<EA> self_type; @@ -100,19 +100,17 @@ public: typedef typename EA::value_type& reference; enumarray_iterator(EA& b, size_t start_pos) - : m_buf(b), m_pos(start_pos) {} - value_type& operator*() const { return m_buf[static_cast<key_type>(m_pos)]; } + : m_buf(&b), m_pos(start_pos) {} + value_type& operator*() const { return (*m_buf)[static_cast<key_type>(m_pos)]; } value_type* operator->() const { return &(operator*()); } self_type& operator++() { ++m_pos; return *this; } - bool operator!=(self_type const & other) const { return &m_buf != &other.m_buf || m_pos != other.m_pos; } - bool operator==(self_type const & other) const { return &m_buf == &other.m_buf && m_pos == other.m_pos; } - enumarray_iterator& - operator=(self_type const & other) { m_buf = other.m_buf; m_pos = other.m_pos; return *this; } + bool operator!=(self_type const & other) const { return m_buf != other.m_buf || m_pos != other.m_pos; } + bool operator==(self_type const & other) const { return m_buf == other.m_buf && m_pos == other.m_pos; } }; template<typename EA> class enumarray_const_iterator { - EA const & m_buf; + EA const * m_buf; size_t m_pos; public: typedef enumarray_const_iterator<EA> self_type; @@ -127,14 +125,12 @@ public: typedef typename EA::value_type const & reference; enumarray_const_iterator(EA const & b, size_t start_pos) - : m_buf(b), m_pos(start_pos) {} - value_type& operator*() const { return m_buf[static_cast<key_type>(m_pos)]; } + : m_buf(&b), m_pos(start_pos) {} + value_type& operator*() const { return (*m_buf)[static_cast<key_type>(m_pos)]; } value_type* operator->() const { return &(operator*()); } self_type& operator++() { ++m_pos; return *this; } - bool operator!=(self_type const & other) const { return &m_buf != &other.m_buf || m_pos != other.m_pos; } - bool operator==(self_type const & other) const { return &m_buf == &other.m_buf && m_pos == other.m_pos; } - enumarray_const_iterator& - operator=(self_type const & other) { m_buf = other.m_buf; m_pos = other.m_pos; return *this; } + bool operator!=(self_type const & other) const { return m_buf != other.m_buf || m_pos != other.m_pos; } + bool operator==(self_type const & other) const { return m_buf == other.m_buf && m_pos == other.m_pos; } }; }; // namespace o3tl _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits