@@ -71,6 +71,10 @@ class CircularBuffer {
7171 size_type _index;
7272 bool _reverse;
7373
74+ bool _comparable (const BufferIterator& other){
75+ return (_ptrToBuffer == other._ptrToBuffer )&&(_reverse == other._reverse );
76+ }
77+
7478 BufferIterator ()
7579 :_ptrToBuffer{nullptr }, _offset{0 }, _index{0 }, _reverse{false }{}
7680
@@ -114,9 +118,69 @@ class CircularBuffer {
114118 BufferIterator iter = *this ;
115119 --_index;
116120 return iter;
121+ }
122+
123+ friend BufferIterator operator +(BufferIterator lhsiter, difference_type n){
124+ lhsiter._index += n;
125+ return lhsiter;
126+ }
127+
128+ friend BufferIterator operator +(difference_type n, BufferIterator rhsiter){
129+ rhsiter._index += n;
130+ return rhsiter;
131+ }
132+
133+ BufferIterator& operator +=(difference_type n){
134+ _index += n;
135+ return *this ;
136+ }
137+
138+ friend BufferIterator operator -(BufferIterator lhsiter, difference_type n){
139+ lhsiter._index -= n;
140+ return lhsiter;
141+ }
142+
143+ BufferIterator& operator -=(difference_type n){
144+ _index -= n;
145+ return *this ;
146+ }
117147
148+ bool operator ==(const BufferIterator& other){
149+ if (!_comparable (other))
150+ return false ;
151+ return ((_index == other._index )&&(_offset == other._offset ));
152+ }
118153
154+ bool operator !=(const BufferIterator& other){
155+ if (!_comparable (other))
156+ return true ;
157+ return ((_index != other._index )||(_offset != other._offset ));
158+ }
159+
160+ bool operator <(const BufferIterator& other){
161+ if (!_comparable (other))
162+ return false ;
163+ return ((_index + _offset)<(other._index +other._offset ));
164+ }
165+
166+ bool operator >(const BufferIterator& other){
167+ if (!_comparable (other))
168+ return false ;
169+ return ((_index + _offset)>(other._index +other._offset ));
170+ }
171+
172+ bool operator <=(const BufferIterator& other){
173+ if (!_comparable (other))
174+ return false ;
175+ return ((_index + _offset)<=(other._index +other._offset ));
119176 }
177+
178+ bool operator >=(const BufferIterator& other){
179+ if (!_comparable (other))
180+ return false ;
181+ return ((_index + _offset)>=(other._index +other._offset ));
182+ }
183+
120184 };
121185};
122186
0 commit comments