diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-11-25 17:05:45 +0100 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2020-05-17 21:39:19 +0200 |
commit | b4836035432a722f171e2eb546e1e8080f2aef64 (patch) | |
tree | 8233ca51956e86d7f2c4b3ac850f3b243fbc0690 /include | |
parent | 6475fd5b4db997d35b52cd5a3294044a62be9dc9 (diff) |
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 <sbergman@redhat.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93693
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/o3tl/enumarray.hxx | 24 |
1 files changed, 10 insertions, 14 deletions
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 |