|
@@ -47,26 +47,35 @@ circular_buffer::const_iterator circular_buffer::const_iterator::operator+(size_
|
|
}
|
|
}
|
|
std::ptrdiff_t circular_buffer::iterator::operator-(const iterator& o)const{
|
|
std::ptrdiff_t circular_buffer::iterator::operator-(const iterator& o)const{
|
|
using ui = std::ptrdiff_t;
|
|
using ui = std::ptrdiff_t;
|
|
- assert(source == o.source);
|
|
|
|
- ui so = m_begin.offset;
|
|
|
|
|
|
+ assert(parent == o.parent);
|
|
|
|
+ ui so = parent->m_begin.offset;
|
|
|
|
+ ui new_this_offset = ((ui)(this->offset) - so) % period;
|
|
|
|
+ ui new_o_offset = ((ui)(o.offset) - so) % period;
|
|
|
|
+ return new_this_offset - new_o_offset;
|
|
}
|
|
}
|
|
std::ptrdiff_t circular_buffer::iterator::operator-(const const_iterator& o)const{
|
|
std::ptrdiff_t circular_buffer::iterator::operator-(const const_iterator& o)const{
|
|
- assert(source == o.source);
|
|
|
|
- if(parent->m_begin.offset < parent->m_end.offset)
|
|
|
|
- return offset - o.offset;
|
|
|
|
- return (offset - o.offset) % period;
|
|
|
|
|
|
+ using ui = std::ptrdiff_t;
|
|
|
|
+ assert(parent == o.parent);
|
|
|
|
+ ui so = parent->m_begin.offset;
|
|
|
|
+ ui new_this_offset = ((ui)(this->offset) - so) % period;
|
|
|
|
+ ui new_o_offset = ((ui)(o.offset) - so) % period;
|
|
|
|
+ return new_this_offset - new_o_offset;
|
|
}
|
|
}
|
|
std::ptrdiff_t circular_buffer::const_iterator::operator-(const iterator& o)const{
|
|
std::ptrdiff_t circular_buffer::const_iterator::operator-(const iterator& o)const{
|
|
- assert(source == o.source);
|
|
|
|
- if(parent->m_begin.offset < parent->m_end.offset)
|
|
|
|
- return offset - o.offset;
|
|
|
|
- return (offset - o.offset) % period;
|
|
|
|
|
|
+ using ui = std::ptrdiff_t;
|
|
|
|
+ assert(parent == o.parent);
|
|
|
|
+ ui so = parent->m_begin.offset;
|
|
|
|
+ ui new_this_offset = ((ui)(this->offset) - so) % period;
|
|
|
|
+ ui new_o_offset = ((ui)(o.offset) - so) % period;
|
|
|
|
+ return new_this_offset - new_o_offset;
|
|
}
|
|
}
|
|
std::ptrdiff_t circular_buffer::const_iterator::operator-(const const_iterator& o)const{
|
|
std::ptrdiff_t circular_buffer::const_iterator::operator-(const const_iterator& o)const{
|
|
- assert(source == o.source);
|
|
|
|
- if(parent->m_begin.offset < parent->m_end.offset)
|
|
|
|
- return offset - o.offset;
|
|
|
|
- return (offset - o.offset) % period;
|
|
|
|
|
|
+ using ui = std::ptrdiff_t;
|
|
|
|
+ assert(parent == o.parent);
|
|
|
|
+ ui so = parent->m_begin.offset;
|
|
|
|
+ ui new_this_offset = ((ui)(this->offset) - so) % period;
|
|
|
|
+ ui new_o_offset = ((ui)(o.offset) - so) % period;
|
|
|
|
+ return new_this_offset - new_o_offset;
|
|
}
|
|
}
|
|
|
|
|
|
circular_buffer::iterator& circular_buffer::iterator::operator=(const circular_buffer::iterator& o){
|
|
circular_buffer::iterator& circular_buffer::iterator::operator=(const circular_buffer::iterator& o){
|