From b14bb04d4de155c22dcb13a03c677cec37b178c4 Mon Sep 17 00:00:00 2001 From: Ali Ghaffaari Date: Tue, 8 Dec 2020 18:17:17 +0100 Subject: [PATCH] Use pointer to the container for int_vector_buffer iterator Using reference member prevents defining assignment operator for the iterator class of int_vector_buffer. This commit fixes #436. --- include/sdsl/int_vector_buffer.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/sdsl/int_vector_buffer.hpp b/include/sdsl/int_vector_buffer.hpp index 601701506..85cc51a46 100644 --- a/include/sdsl/int_vector_buffer.hpp +++ b/include/sdsl/int_vector_buffer.hpp @@ -39,6 +39,7 @@ class int_vector_buffer class iterator; typedef typename int_vector::difference_type difference_type; typedef typename int_vector::value_type value_type; + typedef typename int_vector::size_type size_type; private: static_assert(t_width <= 64 , "int_vector_buffer: width must be at most 64 bits."); @@ -489,12 +490,12 @@ class int_vector_buffer class iterator: public std::iterator { private: - int_vector_buffer& m_ivb; + int_vector_buffer* m_ivb; uint64_t m_idx = 0; public: iterator() = delete; - iterator(int_vector_buffer& ivb, uint64_t idx=0) : m_ivb(ivb), m_idx(idx) {} + iterator(int_vector_buffer& ivb, uint64_t idx=0) : m_ivb(&ivb), m_idx(idx) {} iterator& operator++() { @@ -524,7 +525,7 @@ class int_vector_buffer reference operator*()const { - return m_ivb[m_idx]; + return (*m_ivb)[m_idx]; } iterator& operator+=(difference_type i) @@ -557,7 +558,7 @@ class int_vector_buffer bool operator==(const iterator& it) const { - return &m_ivb == &(it.m_ivb) and m_idx == it.m_idx; + return m_ivb == it.m_ivb and m_idx == it.m_idx; } bool operator!=(const iterator& it) const