Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2002-10-17 19:31:51


On Thursday, October 17, 2002, at 07:28 PM, Victor A. Wagner, Jr.
wrote:

> I'm dismayed (slightly) to discover that the containerators I wrote a
> year ago aren't really conforming bidirectional iterators. You know,
> in all that time, nobody's complained? Am I going to fix them? Not
> for the original users, I don't work there anymore. Do I think that
> doubling the memory requirements just so someone can do the equivalent
> of --end() is worth it? Not really. Maybe we need a new class called
> either-directional which becomes testable when it "steps off the end"
> but that can't "come back".

Go for it:

struct eitherdirectional_iterator_tag : std::forward_iterator_tag {};

Now your code can test on the iterator_category being
eitherdirectional_iterator_tag, and act accordingly. And when you send
your iterator to code ignorant of your new classification (such as
std::algorithms) it will still function well as a forward iterator
(provided you've met those constraints).

-Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk