<div dir="ltr">I have an object for which operator &lt;&lt; is defined, myobj.<div><br></div><div>I want to compress into a buffer, and I know that this can be done with boost. I would prefer a buffer that dynamically resizes, but that only allocates new space, preferably treating discontiguous space brought on by new allocations as though the whole buffer was one piece; I don&#39;t want to find that it&#39;s copying data at all. So vector won&#39;t work as a buffer; there&#39;s no need for it to be contiguous, just as fast as possible.</div>
<div><br></div><div>I&#39;ve been trying to do this with filtering_istreambuf by pushing a bzip2_compressor (any compression filter will work). So far, it&#39;s giving me a lot of trouble. I did find an example where a string was passed to a function, but they went through a process where they first moved the string into an stringstream. I don&#39;t want to settle for that extra copy either.</div>
<div><br></div><div>What would be nice is to be able to do something like</div><div><br></div><div>compressor &lt;&lt; myobj</div><div><br></div><div>compressor.buf(); //returns compressed myobj output</div></div>