
christopher diggins <cdiggins@videotron.ca> writes:
That would be useful, however your sample code has a problem with the end iterator. To iterate over every second element of a container that has an even length, the one-past-the-end stride-2 iterator is actually TWO past the end of the original container. Unless you have a special container where incrementing beyond the one-past-the-end is allowed, you need another solution (indexing?).
Would indexing not lead to a similar problem? I would have thought the only way out is to pass a size parameter to the iterator. Do any iterators exist which do not allow incrementing past one past the end?
When the step size is 3 you go 2 past the end. -- Dave Abrahams Boost Consulting www.boost-consulting.com