Boost logo

Boost :

From: Dave Abrahams (abrahams_at_[hidden])
Date: 1999-11-29 00:28:03


> 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
help.

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
specialization).

-Dave


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