|
Boost : |
Subject: Re: [boost] [explore] Library Proposal: Container Streaming
From: Jeffrey Faust (jeff_at_[hidden])
Date: 2009-12-01 19:47:05
Another thing that explore provides beyond the basic 'cout << c'
is a set of extendable manipulators. These behave like existing
std manipulators to modify the formatting of the output. Love
them or hate them, they are familiar to a large base of developers.
In particular, the cols and item_width manipulators together
provide a simple but powerful way to stream numeric data.
Can either serialization or karma handle this as easily?
-- Jeff Faust
#include <boost/explore/map.hpp>
#include <boost/explore/vector.hpp>
#include <iostream>
#include <string>
using namespace std;
using namespace boost::explore;
int main()
{
map<int, string> mis;
cout << mis << endl;
// []
mis[1] = "Hello";
cout << mis << endl;
// [1:Hello]
cout << quote_strings << mis << endl;
// [1:"Hello"]
vector<int> vi;
for( int i = 1; i <= 9; ++i )
vi.push_back(i*2);
cout << vi << endl;
// [2, 4, 6, 8, 10, 12, 14, 16, 18]
cout << delimiters("", " ", "");
cout << vi << endl;
// 2 4 6 8 10 12 14 16 18
cout << cols(3) << vi << endl;
// 2 4 6
// 8 10 12
// 14 16 18
cout << item_width(3) << vi << endl;
// 2 4 6
// 8 10 12
// 14 16 18
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk