[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - include/o3tl
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Sun May 17 19:39:49 UTC 2020
include/o3tl/enumarray.hxx | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
New commits:
commit b4836035432a722f171e2eb546e1e8080f2aef64
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Mon Nov 25 17:05:45 2019 +0100
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Sun May 17 21:39:19 2020 +0200
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 at redhat.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93693
Reviewed-by: Tor Lillqvist <tml at collabora.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
More information about the Libreoffice-commits
mailing list