]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
chore: fix two usages of std::iterator (deprecated) 61909/head
authorPaul Stemmet <github@luxolus.com>
Wed, 19 Feb 2025 16:33:39 +0000 (16:33 +0000)
committerPaul Stemmet <github@luxolus.com>
Tue, 25 Feb 2025 10:58:05 +0000 (10:58 +0000)
This trait has been deprecated in C++17, with users instructed to
migrate to defining each associated type when implementing an iterator.

This quiets the _GLIBCXX17_DEPRECATED warnings when compiling the
project on a sufficiently new gcc.

This follows on from previous efforts in 8b8a96d (#45198).

References: https://github.com/ceph/ceph/pull/45198
References: https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/
Signed-off-by: Paul Stemmet <github@luxolus.com>
src/include/rangeset.h
src/msg/async/dpdk/circular_buffer.h

index e7e3d047c72aa40a76d154944e91a0ba45d71745..f19af0b61e42f32626db44105fb42ae2189176dd 100644 (file)
@@ -55,9 +55,14 @@ struct _rangeset_base {
 
 
 template <class T>
-class rangeset_iterator :
-  public std::iterator<std::input_iterator_tag, T>
+class rangeset_iterator
 {
+    using iterator_category = std::input_iterator_tag;
+    using value_type = T;
+    using difference_type = std::ptrdiff_t;
+    using pointer = T*;
+    using reference = T&;
+
   //typedef typename map<T,T>::iterator mapit;
 
   map<T,T> ranges;
index 2c92c12044408ad5cc2e4cb15a37108ec5789f81..bf5d422dac6cdf0aed2c12d3526f3545b4bdc0f3 100644 (file)
@@ -89,8 +89,12 @@ class circular_buffer {
   size_t mask(size_t idx) const;
 
   template<typename CB, typename ValueType>
-  struct cbiterator : std::iterator<std::random_access_iterator_tag, ValueType> {
-    typedef std::iterator<std::random_access_iterator_tag, ValueType> super_t;
+  struct cbiterator {
+    using iterator_category = std::random_access_iterator_tag;
+    using value_type = ValueType;
+    using difference_type = std::ptrdiff_t;
+    using pointer = ValueType*;
+    using reference = ValueType&;
 
     ValueType& operator*() const { return cb->_impl.storage[cb->mask(idx)]; }
     ValueType* operator->() const { return &cb->_impl.storage[cb->mask(idx)]; }
@@ -116,17 +120,17 @@ class circular_buffer {
       idx--;
       return v;
     }
-    cbiterator<CB, ValueType> operator+(typename super_t::difference_type n) const {
+    cbiterator<CB, ValueType> operator+(difference_type n) const {
       return cbiterator<CB, ValueType>(cb, idx + n);
     }
-    cbiterator<CB, ValueType> operator-(typename super_t::difference_type n) const {
+    cbiterator<CB, ValueType> operator-(difference_type n) const {
       return cbiterator<CB, ValueType>(cb, idx - n);
     }
-    cbiterator<CB, ValueType>& operator+=(typename super_t::difference_type n) {
+    cbiterator<CB, ValueType>& operator+=(difference_type n) {
       idx += n;
       return *this;
     }
-    cbiterator<CB, ValueType>& operator-=(typename super_t::difference_type n) {
+    cbiterator<CB, ValueType>& operator-=(difference_type n) {
       idx -= n;
       return *this;
     }
@@ -148,7 +152,7 @@ class circular_buffer {
     bool operator<=(const cbiterator<CB, ValueType>& rhs) const {
       return idx <= rhs.idx;
     }
-    typename super_t::difference_type operator-(const cbiterator<CB, ValueType>& rhs) const {
+    difference_type operator-(const cbiterator<CB, ValueType>& rhs) const {
       return idx - rhs.idx;
     }
    private: