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

From: Ed Johnson [mailto:ed@edwardotis.com]
Thanks, I see where I was not using the correct constructor before. However, even when I use the proper one, I get the same results. I cannot get the '<<' operator to append to the original string that I pass using the stringstream constructor. It still begins at the first character and begins overwriting the string.
//constructor syntax explicit stringstream ( openmode mode = in | out ); explicit stringstream ( const string & str, openmode mode = in | out );
//updated code boost::shared_ptr< std::stringstream > sharedStream(new
std::stringstream("hello world", std::stringstream::out));
Is there something else I'm missing?
I think you have to use the "ate" or "app" openmode for that. HTH, Éric

EMalenfant@interstarinc.com wrote:
From: Ed Johnson [mailto:ed@edwardotis.com]
Thanks, I see where I was not using the correct constructor before. However, even when I use the proper one, I get the same results. I cannot get the '<<' operator to append to the original string that I pass using the stringstream constructor. It still begins at the first character and begins overwriting the string.
//constructor syntax explicit stringstream ( openmode mode = in | out ); explicit stringstream ( const string & str, openmode mode = in | out );
//updated code boost::shared_ptr< std::stringstream > sharedStream(new
std::stringstream("hello world", std::stringstream::out));
Is there something else I'm missing?
I think you have to use the "ate" or "app" openmode for that.
HTH,
Éric
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 )); boost::shared_ptr< std::stringstream > sharedStream(new std::stringstream("hello world", std::stringstream::out | std::stringstream::app )); boost::shared_ptr< std::stringstream > sharedStream(new std::stringstream("hello world", std::stringstream::app )); boost::shared_ptr< std::stringstream > sharedStream(new std::stringstream("hello world", std::stringstream::ate )); Thanks, Ed
participants (2)
-
Ed Johnson
-
EMalenfant@interstarinc.com