Boost logo

Boost :

From: garcia (garcia_at_[hidden])
Date: 2003-12-04 18:59:25

John Torjo wrote:

> Dear boosters,
> I browsed the sandbox, but could not find a simpler ostream_iterator.
> The thing is that I don't like the fact that when writing using an
> ostream_iterator I have to provide the value_type I'm writing.
> This is both tedios and error prone.
> Example:
> std::copy( vs.begin(), vs.end(),
> std::ostream_iterator<std::string>(std::cout, " "));
> ^^^ tedious and error prone.
> This should not be necessary since it can be deduced at the time of
> writing.
> I wrote a small helper. Any interest in adding it to boost?

At least from my perspective, the only thing I tend to use
ostream_iterator for is to stream a container of stuff to std::cout, or
the like, as you do above. A while back I wrote some helpers so that
the syntax becomes more like:

std::cout << "Stuff follows:\n" << stream_range(vs.begin(),vs.end(),",")
<< "\n";

I like this a lot better, though I must admit that ostream_iterator is a
little more flexible. But I usually use this kind of thing for
debugging or personal programming projects.



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