Boost logo

Boost :

From: Jan Gaspar (jano_gaspar_at_[hidden])
Date: 2004-04-13 01:40:03

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);
// ...
circular_buffer<int>::iterator it1 = cb.end() + 1; //
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

Best regards,


--- "Neal D. Becker" <ndbecker2_at_[hidden]> 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:

Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway

Boost list run by bdawes at, gregod at, cpdaniel at, john at