Boost logo

Boost Users :

From: james.jones_at_[hidden]
Date: 2006-05-16 09:08:59

From: Ed Johnson <ed_at_[hidden]>
> Hi Eric,
> I tried and none of the following modes worked.
>boost::shared_ptr< std::stringstream > sharedStream(new
>std::stringstream("hello world", std::stringstream::out |
>std::stringstream::ate ));

[other examples snipped]


I think you should prove this isn't a boost::shared_ptr issue first. Have you tried it with a raw pointer? I suspect you'll get the exact same results as with boost::shared_ptr, which would indicate a problem with your implementation of std::stringstream, not with boost::shared_ptr. Your prior example was this:

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

But this is a different call pattern, not just a change from an object to a smart pointer. This probably works fine:

boost::shared_ptr<std::stringstream> tr(new std::stringstream());
(*tr) << "hello, world";
(*tr) << "!";
std::cerr << tr->str() << std::endl;

And this probably doesn't work:

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

If I'm right in both cases, your problem is with std::stringstream, not with boost::shared_ptr.

James Jones Administrative Data Mgmt.
Webmaster 375 Raritan Center Pkwy, Suite A
Data Architect Edison, NJ 08837

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