Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2004-09-10 15:02:56


"Brian Braatz" <brianb_at_[hidden]> writes:

> I have worked through the tutorial on iterator_facade. (extremely cool
> library)- and I am reading about iterator_adapter- but what I am not
> seeing is the high level picture here.
>
> My Question:
>
> In a nutshell- what is the basic difference between iterator_adapter
> and iterator_facade?
>
> When would I use one over the other?

iterator_adaptor is useful when you have some iterator or
iterator-like type that already implements most of the behaviors of
your final iterator. If you can say "the resulting iterator acts just
like the Base type T *except...*", then you probably want
iterator_adaptor. Most of the specialized adaptors in the iterators
library use iterator_adaptor. For example, transform_iterator acts
just like its Base iterator *except that the result of dereferencing
it is passed through a function." If you are just building an
iterator "from scratch," use iterator_facade. See the filesystem
library's directory_iterator for example.

HTH,

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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