Boost logo

Boost Users :

Subject: Re: [Boost-users] boost replacement for std::ostringstream
From: Chris Stankevitz (chrisstankevitz_at_[hidden])
Date: 2012-09-07 12:49:58


On Thu, Sep 6, 2012 at 11:17 PM, Szymon Gatner <szymon.gatner_at_[hidden]> wrote:
> You could use filtering_ostream with underlying vector and reserve()
> on that vector.

Szymon,

Thank you that is exactly what I did:

#include <boost/iostreams/device/back_inserter.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#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

  // use Result...

Chris


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net