ring_buffer_iterator: add it1 - it2 operator

This commit is contained in:
Ferdinand Bachmann
2021-03-10 13:46:27 +01:00
parent 795a4c3be7
commit 5a6309dc28

View File

@@ -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());
}