Date: 1999-11-29 00:35:50
Sorry, I'll try to reword that, though realize that in the final
analysis I agreed with your suggestion.
The original version of the random_access_helper did not define
the random_access_iterator_tag. Using that version, someone could
reasonably have an iterator that is not a RandomAccessIterator
(because it is missing operator-) but still use the helper.
Now the reason we added the random_access_iterator_tag was
merely for convenience, but once we make that addition, as
you've pointed out, we really should require the operator-.
So the issue then is, do we want to make the helper usable
by almost-random-access-iterators, or do we want to provide
the convenience of the tag definition. I would go with the
convenience of the tag definition, even though it narrows
(very slightly) the number of situations that the helper
can be used.
Dave Abrahams writes:
> > Dave Abrahams writes:
> > > Except that if you don't have a random access iterator unless op- is
> > > supported. Whether an algorithm chooses to make use of op- is an
> > > implementation detail. If you give an iterator's traits the tag
> > > random_access_iterator_tag, but you don't define op-, you're essentially
> > > lying to whatever library is going to use the traits.
> > True, if we define the random_access_iterator_tag, the iterator
> > should be a RandomAccessIterator. But on the other hand, the
> > random_access_iterator_tag was added only as a convenience to the
> > user. In general I am against adding extra requirements that aren't
> > really needed (it is a barrier to reuse).
> 1. I don't understand your argument at all. Perhaps some elaboration would
> 2. Using a type whose iterator_traits say it is a RandomAccessIterator, but
> which doesn't define op- could easily cause a standard algorithm to fail to
> compile when used with it, wheras if you told the truth and said it was a
> BidirectionalIterator, the algorithm would compile just fine (because of
> -- Talk to your group with your own voice!
> -- http://www.egroups.com/VoiceChatPage?listName=boost&m=1
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk