|
Boost : |
From: David Abrahams (abrahams_at_[hidden])
Date: 2001-06-07 13:25:02
----- Original Message -----
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.
> Note that for ostream_iterator<int> it, *it = 5, *it = 'X', *it = 3.14
> are equally valid.
Erf. What's the point of the template parameter, then? Oh, you mean that the
expressions are valid because int converts implicitly from char and
double... a red herring, no?
> My_cute_ostream_iterator would produce nicer
> results.
Sure.
> I once wanted the value_type of an output iterator in an algorithm,
> but knowing what the algorithm did and the value_type of the
> input iterator allowed me to declare a local of an appropriate
> type. It might not be the same as the output iterator, but the
> assignment would work.
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...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk