Boost logo

Boost Users :

From: Ed Johnson (ed_at_[hidden])
Date: 2006-05-14 14:32:29


  Is it possible to use shared_ptr to manage stringstreams, and still
use the << operator on the stringstream?


//I would like to print 'hello world!' in both cases
#include <iostream>

boost::shared_ptr< std::stringstream > sharedStream(new
std::stringstream("hello world"));

(*sharedStream) << "!";
std::cerr << (*sharedStream).str() << std::endl;

std::stringstream tr;
tr << "hello world";
tr << "!";
std::cerr << tr.str() << std::endl;


hello world!

Many thanks,

Ed Johnson

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at