Boost logo

Boost :

From: Jonathan Wakely (cow_at_[hidden])
Date: 2005-06-15 12:16:12

On Wed, Jun 15, 2005 at 12:01:27PM -0400, David Abrahams wrote:

> Jonathan Wakely <cow_at_[hidden]> writes:
> > On Wed, Jun 15, 2005 at 10:24:10AM +0200, Thorsten Ottosen wrote:
> >
> >> "David Abrahams" <dave_at_[hidden]> wrote in message
> >>
> >>
> >> | If someone would clearly and succinctly spell out the question, I'd be
> >> | happy to.
> >>
> >> should one be able to add, subtract, and compare mutable random access
> >> iterators with
> >> random access const_iterators provided they point to the same container?
> >
> > It's not required for any iterator in general (you can't convert all
> > output iterators to input iterators, for instance ostream_iterator
> > cannot be converted to a read-only iterator type).
> >
> > But the container requirements require that X::iterator be convertible
> > to X::const_iterator, and then all those operations work by using that
> > conversion.
> That's incorrect. For example, if the operations are templated no
> implicit conversion will take place.

That's true, thanks, Dave.

Reading it back I've also realised that the last sentence of mine that
you quote is ambiguous. I didn't mean to suggest that the container
requirements require that those operations use the conversion. The
requirement is that X::iterator is convertible to X::const_iterator.

The operations _could_ work by using that conversion, but aren't
required to.


"I was born not knowing and have had only a little time to
 change that here and there."
	- Feynman

Boost list run by bdawes at, gregod at, cpdaniel at, john at