|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-02-03 13:49:05
From: "Terje Slettebø" <tslettebo_at_[hidden]>
> >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
> >
> > <boost/io/vector.hpp>
> > <boost/io/set.hpp>
> >
> > and so on. [...]
> You can do this quite well using the standard library and stream iterator
> adapters. This may do both of your approaches above. For example:
[...]
> typedef std::ostream_iterator<std::string> Out;
>
> std::cout << "Print vector\n";
> std::copy(list.begin(),list.end(),Out(std::cout,"\n"));
Now try the same with
std::map< std::string, std::vector< std::vector<int > > >.
With op<<, it's still one statement.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk