From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-02-03 12:39:52
>From: "Vladimir Prus" <ghost_at_[hidden]>
> after having to output std::vector to stream again and again using custom
> solution, I started to wonder why we don't have a solution in boost.
> Does it makes sense to include operators<< for vectors, sets, etc?
> I was thinking about
> and so on. There are basically two approaches:
> 1. Operators use fixed format: bracked list with commas between values for
> vector, for example.
> 2. Manipulators are provided to set brackets and separators.
> I had implemented the second approach some time ago, but it turned out
> was overkill. So, 1) looks better now.
You can do this quite well using the standard library and stream iterator
adapters. This may do both of your approaches above. For example:
--- Start ---
typedef std::ostream_iterator<std::string> Out;
std::cout << "Print vector\n";
--- End ---
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk