]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include/buffer: add operator+=() for iterators
authorKefu Chai <kchai@redhat.com>
Fri, 31 Jan 2020 05:02:28 +0000 (13:02 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 1 Feb 2020 15:18:10 +0000 (23:18 +0800)
less type than p.advance(). please note, this does not imply that
list::iterator is a RandomAccessIterator. as the parameter type of
p.adavance() is not `ptrdiff_t`, which is a signed type.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/include/buffer.h

index c77da774e7e0327251abfd1f53a90e4f6fe81ca8..6bcbecc3a820a66c6933d33f6edbb89c968df61f 100644 (file)
@@ -232,6 +232,10 @@ inline namespace v14_2_0 {
        if (pos > end_ptr)
          throw end_of_buffer();
       }
+      iterator_impl& operator+=(size_t len) {
+        advance(len);
+        return *this;
+      }
 
       const char *get_pos() {
        return pos;
@@ -717,10 +721,13 @@ inline namespace v14_2_0 {
        return p == ls->end();
        //return off == bl->length();
       }
-
       void advance(unsigned o);
       void seek(unsigned o);
       char operator*() const;
+      iterator_impl& operator+=(unsigned o) {
+        advance(o);
+        return *this;
+      }
       iterator_impl& operator++();
       ptr get_current_ptr() const;
       bool is_pointing_same_raw(const ptr& other) const;