diff --git a/src/buffer.hh b/src/buffer.hh index 03b96b34..8f3121e5 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -31,7 +31,7 @@ public: typedef size_t difference_type; typedef const value_type* pointer; typedef const value_type& reference; - typedef std::bidirectional_iterator_tag iterator_category; + typedef std::random_access_iterator_tag iterator_category; BufferIterator() : m_buffer(nullptr) {} BufferIterator(const Buffer& buffer, BufferCoord coord); @@ -44,6 +44,7 @@ public: bool operator>= (const BufferIterator& iterator) const; char operator* () const; + char operator[](size_t n) const; size_t operator- (const BufferIterator& iterator) const; BufferIterator operator+ (ByteCount size) const; diff --git a/src/buffer_iterator.inl.hh b/src/buffer_iterator.inl.hh index fb3a8a1d..1d3953ba 100644 --- a/src/buffer_iterator.inl.hh +++ b/src/buffer_iterator.inl.hh @@ -62,6 +62,11 @@ inline char BufferIterator::operator*() const return m_buffer->at(m_coord); } +inline char BufferIterator::operator[](size_t n) const +{ + return m_buffer->at(m_buffer->advance(m_coord, n)); +} + inline size_t BufferIterator::operator-(const BufferIterator& iterator) const { kak_assert(m_buffer == iterator.m_buffer);