C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: ostrstream with gcc-3.2.2

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Samuel Krempp
Guest





PostPosted: Sun Apr 25, 2004 11:20 pm    Post subject: Re: ostrstream with gcc-3.2.2 Reply with quote



le Tuesday 23 March 2004 12:44, [email]google (AT) mueller-tolk (DOT) de[/email] écrivit :

Quote:
Benoît Dejean <bnetNOSPAM (AT) ifrance (DOT) com> wrote in message
news:<pan.2004.03.21.01.05.09.594456 (AT) ifrance (DOT) com>...
#include <sstream
std::ostringsteam *report = 0;

There is no freeze() in ostringstream.
Can you approve the following?

Up to now I reused some ostrstream by doing "seekp(0);",
"rdbuf->freeze(0);" and NO delete[] of the pointer returned by "str()"

With ostringstream I do not need a freeze as std::ostringstream::str()
and std::string take care of the ownership of the buffer. I just say
std::ostringstream::seekp(0) and reuse the stream.

did you get the behaviour you expected after this seekp ?
calling seekp(0) does not reset the end of buffer pointers, so :

ostringstream oss;
oss << "1234567890";
oss.seekp(0);
oss << "abc";
cout << oss.str();

will output "abc4567890", if not, your stdlib is not standard compliant.
(I did see one stdlib with this behaviour. In fact I find this behaviour
more useful, but it's not standard)

I made my own alternative stringstream class, providing the same as
std::stringstream plus some access to the eback, gptr, egptr (and
equivalent pointers for the put area) just for this reason. I can send you
my file if you want.
Then you can "reuse" the stringstream correctly.

I find it sad that stringstream's interface was designed this way, it's much
less flexible and useful than it could with almost the same design and
ease-of-use.

--
Samuel.Krempp
cout << "@" << "crans." << (is_spam ? "trucs.en.trop." : "" )
<< "ens-cachan.fr" << endl;


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.