Topic: pair<iterator> < collection
Author: ncm@netcom.com (Nathan Myers)
Date: 1995/04/04 Raw View
In article <FENSTER.95Apr3173706@ground.cs.columbia.edu>,
Sam Fenster <fenster@ground.cs.columbia.edu> wrote:
> You compare an iterator against an end iterator when it's
> traversing/searching a pre-existing range. Pre-existing ranges *have*
> end iterators. When someone hands you an iterator that helps *define* a
> range, it's serving a different purpose. There may be no other range in
> sight to compare it to. Then you need Null as a standard way to signal
> invalidity.
A range is a *minimal* collection. If what you want requires more
semantics than the minimumn, it's easy enough to provide it:
template <class Iterator>
class MaybeBadRange {
Iterator first;
Iterator last;
bool isgood;
public:
MaybeBadRange(Iterator f, Iterator e, bool ok);
bool is_ok() { return isgood; }
// plus all the standard collection members
};
There you go, no charge. :-)
That's the whole point: you get what you want at amazingly little
expense, and those of us not interested don't pay.
Nathan Myers