
"Jan Gaspar" <jano_gaspar@yahoo.com> wrote (snip using negative values for index in operator[] ) There are few different cases: 1. operator[] for circular_buffer iterator: circular_buffer<int> b(10); ... fill buffer circular_buffer<int>::iterator it = b.begin() + 5; int x = it[-1]; // should return value b[4] I think here negative values should be allowed here (provided they result in valid offset). 2. operator[] for circular_buffer itself: circular_buffer<int> b(10); b.push_back(10); b.push_back(20); b.push_back(33); int x = b[-1]; // this would return value 30, the last one x = b[-2]; // would return 20 This would be new feature, not available in current standard ontainers. I remember some language (forgot name) provides it. I personally would like to have this feature and have it in std::vector/deque too. Alternatively one can think about syntax as: int x = b[boost::end - 1]; to indicate intent and catch possible bugs. (boost::end would be tag type and operator[] would be overloaded.) 3. incrementing/decrementing circular_buffer iterator with automatic wrap-around: I think this (wrap-around) should not be allowed: - it could hide errors - it suggests circular-linked-list semantics (and one can then ask for rotate()) /Pavel