Boost logo

Boost :

From: John E. Potter (jpotter_at_[hidden])
Date: 2001-06-07 17:55:33


On Thu, 7 Jun 2001, David Abrahams wrote:

> From: "John E. Potter" <jpotter_at_[hidden]>
> >
> > > The question remains, however: what is the type of t?
> >
> > Anything which may be used in the expression *a = t. There could be
> > many different types. You don't want me writing
> > my_cute_ostream_iterator with operator= for char, int, and double?
>
> I don't want to disallow it, but I don't think it's worth sacrificing
> value_type on that altar. We could make the same argument about
> InputIterator, I think. The return of operator* is only required to be
> convertible to T, so proxies are allowed.

Not quite the same because the iterator must include a buffer of the
correct type. It also reads on operator++ which can't be overloaded
to tell it what type to read. Distance(Iiter1, Iiter2) is valid.

> Suppose I hand you an OutputIterator and an istream and ask you to read
> values out of the stream and put them into the OutputIterator...

You can't. I would never write a function with that interface. :)

I've done my job as devil's advocate. I'll leave it to you and others
to decide whether this is really a problem for real code or just a
fiction which came to light because of a compiler bug.

John


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