]> git.proxmox.com Git - ceph.git/commitdiff
define iterators without std::iterator<>
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 3 May 2023 11:28:42 +0000 (13:28 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 3 May 2023 14:45:17 +0000 (16:45 +0200)
> std::iterator<> is deprecated in C++17, so let's just define the
> required traits directly.

cherry-picked/backported from upstream PRs:
https://github.com/ceph/ceph/pull/45419/commits
https://github.com/ceph/ceph/pull/45198/commits

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
patches/0019-define-iterators-without-std-iterator.patch [new file with mode: 0644]
patches/series

diff --git a/patches/0019-define-iterators-without-std-iterator.patch b/patches/0019-define-iterators-without-std-iterator.patch
new file mode 100644 (file)
index 0000000..1a8b2cc
--- /dev/null
@@ -0,0 +1,123 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Thomas Lamprecht <t.lamprecht@proxmox.com>
+Date: Wed, 3 May 2023 13:25:08 +0200
+Subject: [PATCH] define iterators without std::iterator<>
+
+> std::iterator<> is deprecated in C++17, so let's just
+> define the required traits directly.
+
+cherry-picked/backported from upstream PRs:
+https://github.com/ceph/ceph/pull/45419/commits
+https://github.com/ceph/ceph/pull/45198/commits
+
+Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+---
+ .../btree/string_kv_node_layout.h             | 27 +++++++++++--------
+ src/include/rados/librados.hpp           |  7 ++++-
+ src/include/xlist.h                      | 15 +++++++++--
+ 3 files changed, 35 insertions(+), 14 deletions(-)
+
+diff --git a/src/crimson/os/seastore/omap_manager/btree/string_kv_node_layout.h b/src/crimson/os/seastore/omap_manager/btree/string_kv_node_layout.h
+index 9948a4292..1bd95415a 100644
+--- a/src/crimson/os/seastore/omap_manager/btree/string_kv_node_layout.h
++++ b/src/crimson/os/seastore/omap_manager/btree/string_kv_node_layout.h
+@@ -294,7 +294,7 @@ class StringKVInnerNodeLayout {
+   friend class delta_inner_t;
+ public:
+   template <bool is_const>
+-  class iter_t : public std::iterator<std::input_iterator_tag, StringKVInnerNodeLayout> {
++  class iter_t {
+     friend class StringKVInnerNodeLayout;
+     template <typename iterator, typename const_iterator>
+@@ -312,17 +312,22 @@ public:
+       uint16_t index) : node(parent), index(index) {}
+   public:
+-    iter_t(const iter_t &) = default;
+-    iter_t(iter_t &&) = default;
+-    iter_t &operator=(const iter_t &) = default;
+-    iter_t &operator=(iter_t &&) = default;
+-
+-    operator iter_t<!is_const>() const {
+-      static_assert(!is_const);
+-      return iter_t<!is_const>(node, index);
+-    }
+-
++    using iterator_category = std::input_iterator_tag;
++    using value_type = StringKVInnerNodeLayout;
++    using difference_type = std::ptrdiff_t;
++    using pointer = StringKVInnerNodeLayout*;
+     using reference = iter_t&;
++
++    iter_t(const iter_t &) = default;
++    iter_t(iter_t &&) = default;
++    iter_t &operator=(const iter_t &) = default;
++    iter_t &operator=(iter_t &&) = default;
++
++    operator iter_t<!is_const>() const {
++      static_assert(!is_const);
++      return iter_t<!is_const>(node, index);
++    }
++
+     iter_t &operator*() { return *this; }
+     iter_t *operator->() { return this; }
+diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp
+index b40d7bf9a..712a5da82 100644
+--- a/src/include/rados/librados.hpp
++++ b/src/include/rados/librados.hpp
+@@ -104,8 +104,13 @@ inline namespace v14_2_0 {
+   };
+   CEPH_RADOS_API std::ostream& operator<<(std::ostream& os, const librados::ObjectCursor& oc);
+-  class CEPH_RADOS_API NObjectIterator : public std::iterator <std::forward_iterator_tag, ListObject> {
++  class CEPH_RADOS_API NObjectIterator {
+   public:
++    using iterator_category = std::forward_iterator_tag;
++    using value_type = ListObject;
++    using difference_type = std::ptrdiff_t;
++    using pointer = ListObject*;
++    using reference = ListObject&;
+     static const NObjectIterator __EndObjectIterator;
+     NObjectIterator(): impl(NULL) {}
+     ~NObjectIterator();
+diff --git a/src/include/xlist.h b/src/include/xlist.h
+index 733a318a9..73e6d8d53 100644
+--- a/src/include/xlist.h
++++ b/src/include/xlist.h
+@@ -159,10 +159,15 @@ public:
+     remove(_back);
+   }
+-  class iterator: std::iterator<std::forward_iterator_tag, T> {
++  class iterator {
+   private:
+     item *cur;
+   public:
++    using iterator_category = std::forward_iterator_tag;
++    using value_type = T;
++    using difference_type = std::ptrdiff_t;
++    using pointer = T*;
++    using reference = T&;
+     iterator(item *i = 0) : cur(i) {}
+     T operator*() { return static_cast<T>(cur->_item); }
+     iterator& operator++() {
+@@ -183,10 +188,16 @@ public:
+   iterator begin() { return iterator(_front); }
+   iterator end() { return iterator(NULL); }
+-  class const_iterator: std::iterator<std::forward_iterator_tag, T> {
++  class const_iterator {
+   private:
+     item *cur;
+   public:
++    using iterator_category = std::forward_iterator_tag;
++    using value_type = T;
++    using difference_type = std::ptrdiff_t;
++    using pointer = const T*;
++    using reference = const T&;
++
+     const_iterator(item *i = 0) : cur(i) {}
+     const T operator*() { return static_cast<const T>(cur->_item); }
+     const_iterator& operator++() {
index 50a8d2820c79ea4ae9d1d45946167659df06a810..7be383fbaba8e3f6f95a3ec97449101ef218f36a 100644 (file)
@@ -12,3 +12,4 @@
 0016-d-rules-fix-no-restart-on-upgrade.patch
 0017-python3.10-pep-620.patch
 0018-fix-lib-fmt-v9-compat.patch
+0019-define-iterators-without-std-iterator.patch