Re: [Boost-users] newbie - boost::shared_ptr of type stringstream using << operator?

From: Ed Johnson
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_ptrstd::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
participants (1)
-
james.jonesīŧ firstinvestors.com