mirror of
https://git.proxmox.com/git/ceph.git
synced 2025-04-28 16:34:15 +00:00
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>
This commit is contained in:
parent
48cf467e51
commit
c9a7474fbd
123
patches/0019-define-iterators-without-std-iterator.patch
Normal file
123
patches/0019-define-iterators-without-std-iterator.patch
Normal file
@ -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++() {
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user