diff --git a/include/ring-buffer-iterator.h b/include/ring-buffer-iterator.h index 9e207a2..f11fc0f 100644 --- a/include/ring-buffer-iterator.h +++ b/include/ring-buffer-iterator.h @@ -41,6 +41,10 @@ public: return {*container_ptr, front, index - n}; } + CONSTEXPR difference_type operator-(const ring_buffer_iterator& other) const NOEXCEPT { + return index - other.index; + } + CONSTEXPR reference operator*() COND_NOEXCEPT(noexcept(container_ptr->begin()) && noexcept(container_ptr->size())) { return *(container_ptr->begin() + (front + index) % container_ptr->size()); } @@ -137,6 +141,10 @@ public: return {*container_ptr, front, index - n}; } + CONSTEXPR difference_type operator-(const ring_buffer_const_iterator& other) const NOEXCEPT { + return index - other.index; + } + CONSTEXPR reference operator*() const COND_NOEXCEPT(noexcept(container_ptr->cbegin()) && noexcept(container_ptr->size())) { return *(container_ptr->cbegin() + (front + index) % container_ptr->size()); }