From 5ab82abbbbcaa762286ed0ab8e07e58c7613d4a0 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 31 Jan 2020 13:02:28 +0800 Subject: [PATCH] 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 --- src/include/buffer.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/include/buffer.h b/src/include/buffer.h index c77da774e7e..6bcbecc3a82 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; -- 2.47.3