
12 Apr
2004
12 Apr
'04
3:22 p.m.
I'm looking at circular_buffer. It appears to me that operator[] uses "add", and that "add" only allows a positive value of offset? It is not difficult to allow arbitrary values, and this is very useful. if "position" is the current "m_first" and "allocated" is the allocated buffer size, the index could be calculated: int index (int offset) const { int x = (offset + position) % int(allocated); if (x >= 0) return x; else return x + allocated; }