From 68b92b9ac119deaca719bed752a421779cb28e0a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 28 Jan 2017 13:06:03 +0000 Subject: [PATCH] Make BufferIterator only a bidirectional iterator Distance computation is too expensive on BufferIterators to treat them as random access. --- src/buffer.hh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/buffer.hh b/src/buffer.hh index c30f93f9..a43458d2 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -55,7 +55,9 @@ public: using difference_type = ssize_t; using pointer = const value_type*; using reference = const value_type&; - using iterator_category = std::random_access_iterator_tag; + // computing the distance between two iterator can be + // costly, so this is not strictly random access + using iterator_category = std::bidirectional_iterator_tag; BufferIterator() : m_buffer(nullptr) {} BufferIterator(const Buffer& buffer, BufferCoord coord);