Preallocate ostringstream buffer

Tech-Archive recommends: Fix windows errors by optimizing your registry



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?

Regards,
Andrew


.



Relevant Pages

  • Re: Preallocate ostringstream buffer
    ... I want to write about 8Mb of data to a ostringstream and I do not ... memory as the data is written. ... With ostrstream I can map the stream onto a preallocated buffer, ...
    (microsoft.public.vc.stl)
  • Re: Preallocate ostringstream buffer
    ... I want to write about 8Mb of data to a ostringstream and I do not ... With ostrstream I can map the stream onto a preallocated buffer, ...
    (microsoft.public.vc.stl)
  • Re: Preallocate ostringstream buffer
    ... 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, ...
    (microsoft.public.vc.stl)
  • Re: ostrstream initial size.
    ... >>ostrstream has been deprecated. ... > There is no way to reserve space in an ostringstream. ... > indeed often a manual buffer is maintained. ... allows one to easily create a stream and streambuffer that uses a ...
    (microsoft.public.vc.stl)
  • Re: Calling external program in C++
    ... hack at overhauling some code I wrote _years_ ago that used an ... ostrstream, so it might benefit from some cleanup): ... ostringstream &) ...
    (comp.lang.cpp)