 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Samuel Krempp Guest
|
Posted: Sun Apr 25, 2004 11:20 pm Post subject: Re: ostrstream with gcc-3.2.2 |
|
|
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 |
|
 |
|
|
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
|
|