Boost logo

Boost :

From: rogeeff (rogeeff_at_[hidden])
Date: 2002-01-29 13:05:44


--- In boost_at_y..., "David Abrahams" <david.abrahams_at_r...> wrote:
>
> ----- Original Message -----
> From: <nbecker_at_f...>
>
>
> > David> You can adapt anything; it doesn't have to be an
iterator. Your
> iterator has
> > David> some state data, right? Just adapt that.
> >
> > Depends what you mean by "adapt". If by "adapt x" you mean "x is
the
> > first parameter to iterator_adaptor"
>
> Yes.
>
> > , then I believe x has to be an
> > iterator. You can't directly adapt a container, for example.
You can
> > adapt the container's iterator.
>
> Trust me, you can. I co-wrote the library, I should know ;^)
>
> > I guess if you want to adapt the container, you have to do it in 2
> > steps. First adapt the container's iterator, then make an object
that
> > uses that adapted iterator.
>
> Not neccessarily.
>
> An example of a non-iterator being adapted is
boost::counting_iterator<int>.
>
> Ints look enough like iterators that this is maybe not such a good
example,
> but you could put any kind of data at all in there. Using an
iterator just
> gets you more convenient defaults for the associated types and
convenient
> behaviors from default_iterator_policies.
>
> For your circular buffer, you'd probably want to use the underlying
iterator
> type as the first parameter, and store the buffer limits in the
policies
> object.

I have implemented class cycle_iterator based on on
iterator_adaptors. It is generic class that will work with any
collection. If it sound interesting I could post the code.

Gennadiy.


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