Re: Preallocate ostringstream buffer
- From: "Jeff F" <not@xxxxxxxxxxxx>
- Date: Thu, 6 Apr 2006 15:58:37 -0400
Tom Widmer [VC++ MVP] wrote:
Andrew Jarvis wrote:
Dear All,
I want to write about 8Mb of data to a ostringstream and I do not
want the stream continually reallocating ever larger chunks of
memory as the data is written.
With ostrstream I can map the stream onto a preallocated buffer, eg.
char *buffer = new char[length];
ostrstream os(buffer, length);
Is a this possible with ostringstream?
No, sadly there is no ostringstream::reserve. Either use ostrstream
(assuming you don't need wide characters) or roll your own.
And the latter is particularly easy with the boost iostreams library, see:
http://www.boost.org/libs/iostreams/doc/index.html.
Jeff Flinn
.
- Follow-Ups:
- Re: Preallocate ostringstream buffer
- From: P.J. Plauger
- Re: Preallocate ostringstream buffer
- References:
- Preallocate ostringstream buffer
- From: Andrew Jarvis
- Re: Preallocate ostringstream buffer
- From: Tom Widmer [VC++ MVP]
- Preallocate ostringstream buffer
- Prev by Date: Re: Preallocate ostringstream buffer
- Next by Date: Re: Preallocate ostringstream buffer
- Previous by thread: Re: Preallocate ostringstream buffer
- Next by thread: Re: Preallocate ostringstream buffer
- Index(es):
Relevant Pages
|