diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-11-25 17:05:45 +0100 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2020-05-17 23:08:28 +0200 |
commit | 05128f486e36b024fc405a3d5ad967df99c58964 (patch) | |
tree | 39c3da8780ef888a44f7ce3ab02cd1ed5f1dcedc /include | |
parent | ddf24f629901715a982bffe7419aadce6afd395a (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.
(Fixes include/o3tl/enumarray.hxx:110:17: error: definition of
implicit copy constructor for
'enumarray_iterator<o3tl::enumarray<GlobalEventId, rtl::OUString> >'
is deprecated because it has a user-declared copy assignment operator
[-Werror,-Wdeprecated-copy])
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/+/94226
Tested-by: Tor Lillqvist <tml@collabora.com>
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 |