Subject: Re: [boost] lifetime of ranges vs. iterators
From: Arno SchÃ¶dl (aschoedl_at_[hidden])
Date: 2008-09-07 11:02:10
>> What are your referring to specificly? If you are referring to storing the
>> predicate or stride length, this is taken care of because the iterator adaptor
>> stack stores this information only once:
>I'm talking about "vertical" redundancies between layers of the stack.
Could you give a specific example?
Each bounded_iterator stores the information pertinent to its own operation (predicate, stride length, transform functor, whatever) + its base bounded iterator. The base bounded_iterator stores either two (for forward iterators: current and end) or three (for bidirectional and random_access: begin, current and end) base iterators.
The only redundancy that I still see is that you may start with a random_access iterator at the base, but somewhere in the stack the traversal category is weakened to forward. Or the user of the iterator only uses forward traversal, although the iterator type would also support bidirectional traversal. Then the base bounded_iterator stores a begin that is never used.
I am not sure this is worth optimizing for, but you could put the desired traversal category into the bounded_iterator template interface:
bounded_iterator< I, traversal_category >
bounded_iterator< char*, forward_traversal > would then be a forward bounded_iterator running on char*, of size 2x sizeof(char*). It only stores current char* and end char*, instead of begin char*, current char* and end char*.
-- Dr. Arno Schoedl Â· aschoedl_at_[hidden] Technical Director think-cell Software GmbH Â· Invalidenstr. 34 Â· 10115 Berlin, Germany http://www.think-cell.com Â· phone +49-30-666473-10 Â· toll-free (US) +1-800-891-8091 Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl Â· Amtsgericht Charlottenburg, HRB 85229
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk