Boost logo

Boost :

From: scleary_at_[hidden]
Date: 2002-10-17 16:10:43


> -----Original Message-----
> From: David A. Greene [mailto:greened_at_[hidden]]
>
> Herve Bronnimann wrote:
>
> > I assume that by fixed-size vectors your mean a sequence container where
> > all the operations insert/erase have been made inacessible?
> > imho you don't need a container adaptor for fixed-size vector. You
> > should rewrite your code to use a range [first,last) instead.
>
> I was thinking more of a vector (or deque) where inserting an
> element on a full container (however "full" is defined) would
> either throw an exception, automatically remove an element from the
> container before inserting the new one or take some other
> policy-dependent action. Ditto on the removal side.

I've often considered an OutputIterator that "trims" its output to be
useful. Though I've never written one, I can think of several cases where
it might be used.

Though I was approaching it from the idea of using Dave Abraham's iterator
adaptor generator to create an iterator adaptor that would pass the data to
its base iterator until a certain condition is reached (e.g., after "n" data
values have been written), and then perform some action if another value is
written (e.g., do nothing, throw an exception, ...)

This might not fit what you're looking for, but you might want to have a
look at Boost.IteratorAdaptor to see if it could support your solution...

Or maybe not. If you're heading for stack/queue-like adaptors for a
fixed-size container, you might want to check out some recent posts on this
list with regard to "circular queues". I didn't follow that discussion
myself, so I couldn't tell you how it ended up...

HTH,
        -Steve


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk