#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/device/back_inserter.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/zlib.hpp>
#include <vector>
#include <string>
#include <iostream>
using namespace boost::iostreams;
int main()
{
std::vector<char> v;
back_insert_device<std::vector<char>> snk{ v };
filtering_ostream os;
os.push(zlib_compressor{});
os.push(snk);
os << "Boost" << std::flush;
os.pop();
array_source src{ v.data(), v.size() };
filtering_istream is;
is.push(zlib_decompressor{});
is.push(src);
std::string s;
is >> s;
std::cout << s << '\n';
system("pause");
}
step1) 下载zlib的源代码zlib-1.2.10.zip,解压缩到d:\thirdparty
step2) 下载boost编译,注意要指定zlib库的文件夹存放位置
bjam toolset=msvc-14.0 --with-iostreams -s ZLIB_SOURCE="d:\thirdparty\zlib-1.2.10" -s ZLIB_INCLUDE="d:\thirdparty\zlib-1.2.10"
step3) 按照点击打开链接此文档使用