forked from Ferdi265/cxx-ring-buffer
ring_buffer_iterator: add it1 - it2 operator
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user