2012/9/7 Chris Stankevitz
On Thu, Sep 6, 2012 at 11:17 PM, Szymon Gatner
wrote: You could use filtering_ostream with underlying vector and reserve() on that vector.
Szymon,
Thank you that is exactly what I did:
#include
#include #include <string> std::string Result;
Result.reserve(99999);
boost::iostreams::filtering_ostream Stream( boost::iostreams::back_inserter(Result));
Stream.write(pBuffer, 99999); // this part is more complicated in my real scenario
Ah, of course you used string directly. May I ask tho: why are you using a stream to write a block of memory to a string? Why not just directly copying it to a vector (or a string)? If there are no filters attached to a filtering_stream then you just add overhead/complexity without any benefit. Cheers, Simon