|
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]
Ed,
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.
Regards,
-
James Jones Administrative Data Mgmt.
Webmaster 375 Raritan Center Pkwy, Suite A
Data Architect Edison, NJ 08837
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net