Boost logo

Boost Users :

From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2002-11-29 19:29:47


--- At Fri, 29 Nov 2002 17:54:08 +0100, Julia Donawald wrote:

>Hi,
>
>I am trying to write my own iterator - class and using for that the
>boost::iterator_adaptor. I could find on the webpage several examples of how
>to connect an existing iterator like std::string::iterator or a simple array
>as "base-class" for my new iterator, but what can I do if I dont have any
>base-iterator? In the documentation I found the following sentence:
>"The Iterator Adaptor library allows you transform an arbitrary ``base''
>type into a standard-conforming iterator with the behaviors you choose.
>Doing so is especially easy if the ``base'' type is itself an iterator."
>In my situation I dont have any base type which is an iterator, so how
>should I now create such a base-type? Which are the specifications of such a
>base-type? Where can I get information on how to create a new base-type?

The base-type is only there for your reference. All references to the
base type are made using the Policy class. Simply specify the int as your
base type and then implement the Policy class accordingly.

You can look at the default policy class for the functions that you need
to implement. The default policy class is a good starting point for an
iterator-like base class, otherwise it makes a good example of what
functions to implement.

It took me a while to understand this arrangment but once you understand
that the base is for your policy, then it becomes clearer. The policy
class basically operates on the base class. The base class maintains the
"position" and reference information about the iterator.

Good luck.

 ...Duane


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net