Boost logo

Boost :

Subject: [boost] [explore] Library Proposal: Container Streaming
From: Jeffrey Faust (jeff_at_[hidden])
Date: 2009-11-30 10:59:03


Jared McIntyre, Danny Havenith, and myself, with support from Jeff
Garland have developed a library to stream standard containers to output
streams. We would like to submit this for review. The requirements for
this library were gathered at the BoostCon 2007 Library in a Week
sessions. An initial review was held and further requirements were
gathered at BoostCon 2008.

Everything can be found in the boost vault
<http://www.boostpro.com/vault/> . Here is a direct link to explore.zip
<http://www.boostpro.com/vault/index.php?action=downloadfile&filename=ex
plore.zip&directory=&> .

Some quick examples:

#include <boost/explore.hpp>
# include ...

// simple vector example
std::vector<int> vi;
vi.push_back(1);
vi.push_back(2);
vi.push_back(3);
std::cout << vi; // prints [1, 2, 3]

// lets do some containers in containers
std::vector<std::vector<int> > vvi;
vvi.push_back(vi);
vvi.push_back(vi);
std::cout << vvi; // prints [[1, 2, 3], [1, 2, 3]]

// associative containers
std::map<std::string, int> si_map;
si_map["hello"] = 1;
si_map["world"] = 2;
std::cout << si_map; // prints [hello:1, world:2]

// containers of complex types
std::list<date> dl; // date from boost::gregorian
dl.push_back(date(2007, Jan, 1));
dl.push_back(date(2007, Jan, 3));
std::cout << dl; // prints [2007-Jan-1, 2007-Jan-3]

// how about some boost container types:
boost::array<std::string, 2> sa2;
sa2[0] = "one";
sa2[1] = "two";
std::cout << sa2; // prints [one, two]
 
 
Jeffrey Faust


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk