From c9a7474fbd798e34fa7cc8ac97d17505b57eab0c Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 3 May 2023 13:28:42 +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 --- ...efine-iterators-without-std-iterator.patch | 123 ++++++++++++++++++ patches/series | 1 + 2 files changed, 124 insertions(+) create mode 100644 patches/0019-define-iterators-without-std-iterator.patch diff --git a/patches/0019-define-iterators-without-std-iterator.patch b/patches/0019-define-iterators-without-std-iterator.patch new file mode 100644 index 000000000..1a8b2cc9f --- /dev/null +++ b/patches/0019-define-iterators-without-std-iterator.patch @@ -0,0 +1,123 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Thomas Lamprecht +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 +--- + .../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 +- class iter_t : public std::iterator { ++ class iter_t { + friend class StringKVInnerNodeLayout; + + template +@@ -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() const { +- static_assert(!is_const); +- return iter_t(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() const { ++ static_assert(!is_const); ++ return iter_t(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 { ++ 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 { ++ 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(cur->_item); } + iterator& operator++() { +@@ -183,10 +188,16 @@ public: + iterator begin() { return iterator(_front); } + iterator end() { return iterator(NULL); } + +- class const_iterator: std::iterator { ++ 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(cur->_item); } + const_iterator& operator++() { diff --git a/patches/series b/patches/series index 50a8d2820..7be383fba 100644 --- a/patches/series +++ b/patches/series @@ -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