
Hi Neal! I didn't considered this feature important. Moreover it would complicate the iterator. Currently these expressions are invalid: circular_buffer<int> cb(10); cb.push_back(1); // ... circular_buffer<int>::iterator it1 = cb.end() + 1; // invalid circular_buffer<int>::iterator it2 = cb.begin() - 1; // invalid (see Caveats section in docs) I think if I allowed negative indexes or indexes "out of range" I had to change the iterator, too. On the other hand it is not difficult to create an adaptor and someone can make one if he needs such feature. Best regards, Jan --- "Neal D. Becker" <ndbecker2@verizon.net> wrote:
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; }
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boostp://lists.boost.org/mailman...
__________________________________ Do you Yahoo!? Yahoo! Small Business $15K Web Design Giveaway http://promotions.yahoo.com/design_giveaway/