<div dir="ltr">I figured out how to do it:<div>filtering_ostream fos;</div><div>fos.push(back_insert_device<string>(x));</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 14, 2014 at 9:09 AM, Kenneth Adam Miller <span dir="ltr"><<a href="mailto:kennethadammiller@gmail.com" target="_blank">kennethadammiller@gmail.com</a>></span> wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">So, I found that I could use a array_sink and pass it the location and size of an array to use. But now I need to know, when bytes are written in, how much is written into it in order that I can get that exact data out. I also need to make sure that, in the case of something like not enough space occurring, I can still get the rest of the data compressed.<div> <br></div><div>Is there anything that I can pass to an array_sink initializer other than a char * pointer that might help me accomplish this?</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br> <div class="gmail_quote">On Tue, Jan 14, 2014 at 8:20 AM, Kenneth Adam Miller <span dir="ltr"><<a href="mailto:kennethadammiller@gmail.com" target="_blank">kennethadammiller@gmail.com</a>></span> wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I have an object for which operator << 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't want to find that it's copying data at all. So vector won't work as a buffer; there's no need for it to be contiguous, just as fast as possible.</div> <div><br></div><div>I've been trying to do this with filtering_istreambuf by pushing a bzip2_compressor (any compression filter will work). So far, it'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'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 << myobj</div><div><br></div><div>compressor.buf(); //returns compressed myobj output</div></div> </blockquote></div><br></div> </div></div></blockquote></div><br></div>