From: Kefu Chai Date: Fri, 31 Jan 2020 05:02:28 +0000 (+0800) Subject: include/buffer: add operator+=() for iterators X-Git-Tag: v15.1.1~550^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=5ab82abbbbcaa762286ed0ab8e07e58c7613d4a0;p=ceph.git include/buffer: add operator+=() for iterators 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 --- diff --git a/src/include/buffer.h b/src/include/buffer.h index c77da774e7e03..6bcbecc3a820a 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -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;