Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-04-18 10:02:37


David Abrahams wrote:

> > I can't find the description of methods for "Derived" class of
> > iterator_facade, for example.
>
> Um, that's private, so it won't be documented (thanks Thomas!)

Eh.. later you say

   You need to implement at least advance, increment, equal, and
   dereference.

but aren't those defined in "Derived"? And there's not list of methods I
should implement.

> > 2. What is the relation with "new iterator categories". Am I
> > supposed to pass old categories as template parameters to
> > facade/adapter.
>
> New or old; either one should work.

OK.

> > 3. The attached code does not compile with gcc 3.2, saying that:
> >
> > /usr/include/c++/3.2/bits/stl_iterator_base_types.h:123: no type named
> > ` iterator_category' in `class my_old_iterator'
> >
> > The message is correct, but... I've explicitly specified iterator
> > category when declaring iterator adaptor. Am I doing something wrong?
>
> Yes, lots!
>
> You need to implement at least advance, increment, equal, and
> dereference in your derived iterator class in order to make a forward
> iterator.

I understand. I planed to implement them later (they are not needed until
used, right?)

> Also, since your Base type is not an iterator, you need to
> supply a difference_type for your adapted iterator

That was the cause for the error, thanks. (But it wasn't obvious!)

> (and there's no eol at eof ;-)).

:-)

> Also, for your particular application it looks like you might do
> better by just using iterator_facade rather than iterator_adaptor. I
> quote:
>
> To automate the repetitive work of constructing iterators, we
> propose ``iterator_facade``, an iterator base class template which
> provides the rich interface of standard iterators and delegates
> its implementation to member functions of the derived class. We
> also propose ``iterator_adaptor``, a base class generator designed
> specifically for creating iterator adaptors. Because iterators
> usually have many of the features of their underlying iterator
> type, the default features of ``iterator_adaptor`` are those of
> its base [#base]_. The user can selectively replace these features
> in a derived iterator class.

Probably. I was just getting lazy and wanted iterator_adaptor to define member
variable of 'Base' kind for me.

Thanks,
Volodya


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