Ticket #2411: istream_bzip2_failure.cpp

File istream_bzip2_failure.cpp, 718 bytes (added by rbock@…, 14 years ago)

This example demonstrates filtering_istream not releasing any bzip2-compressed data (at least on my machine, the reported length of the compressed string is 0)

Line 
1#include <iostream>
2
3#include <boost/iostreams/filtering_stream.hpp>
4#include <boost/iostreams/copy.hpp>
5#include <boost/iostreams/device/back_inserter.hpp>
6#include <boost/iostreams/filter/bzip2.hpp>
7
8using namespace std;
9
10int main()
11{
12 string source("Original");
13 string bzip2String;
14
15 // Create compressing stream based on original input
16 boost::iostreams::filtering_istream compressingStream;
17 compressingStream.push(boost::iostreams::bzip2_compressor());
18 compressingStream.push(boost::make_iterator_range(source));
19
20 boost::iostreams::copy(compressingStream, boost::iostreams::back_inserter(bzip2String));
21
22 cerr << "length of bzip2String: " << bzip2String.size() << endl;
23
24 return 0;
25}
26