#include #include #include #include #include #include int main() { typedef std::vector buffer_t; buffer_t myBuffer; for (char i=0; i++; i<100) myBuffer.push_back('A'); boost::interprocess::bufferstream input_stream; input_stream.buffer (myBuffer.data(), myBuffer.size()); boost::interprocess::basic_vectorstream compressorOutput; boost::iostreams::filtering_streambuf encoderFilter; encoderFilter.push(boost::iostreams::bzip2_compressor()); encoderFilter.push(input_stream); boost::iostreams::copy(encoderFilter, compressorOutput); buffer_t *myCompressedBuffer = new buffer_t (compressorOutput.vector()); return 0; }