High level question on iterator_adaptor vs iterator_facade
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? Any thoughts appreciated thanks Brian
"Brian Braatz"
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
participants (2)
-
Brian Braatz
-
David Abrahams