Boost Gzip 过滤器:编译失败
我正在尝试从 Boost Gzip 过滤器页面编译示例:
#include <fstream>
#include <iostream>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
int main()
{
using namespace std;
ifstream file("hello.gz", ios_base::in | ios_base::binary);
filtering_streambuf<input> in;
in.push(gzip_decompressor());
in.push(file);
boost::iostreams::copy(in, cout);
}
遗憾的是我的 g++ 返回错误:
gzlib.cpp: In function ‘int main()’:
gzlib.cpp:12:3: error: ‘filtering_streambuf’ was not declared in this scope
gzlib.cpp:12:23: error: ‘input’ was not declared in this scope
gzlib.cpp:12:30: error: ‘in’ was not declared in this scope
gzlib.cpp:13:29: error: ‘gzip_decompressor’ was not declared in this scope
这个函数有什么问题以及如何修改它以使其工作?多谢!
Boost Gzip 过滤器链接: http://www.boost.org/ doc/libs/release/libs/iostreams/doc/classes/gzip.html
I'm trying to compile example from Boost Gzip filters page:
#include <fstream>
#include <iostream>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
int main()
{
using namespace std;
ifstream file("hello.gz", ios_base::in | ios_base::binary);
filtering_streambuf<input> in;
in.push(gzip_decompressor());
in.push(file);
boost::iostreams::copy(in, cout);
}
Sadly my g++ returns errors:
gzlib.cpp: In function ‘int main()’:
gzlib.cpp:12:3: error: ‘filtering_streambuf’ was not declared in this scope
gzlib.cpp:12:23: error: ‘input’ was not declared in this scope
gzlib.cpp:12:30: error: ‘in’ was not declared in this scope
gzlib.cpp:13:29: error: ‘gzip_decompressor’ was not declared in this scope
What's wrong with this function and how to modify it to make it work? Thanks a lot!
Link to Boost Gzip filters: http://www.boost.org/doc/libs/release/libs/iostreams/doc/classes/gzip.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是您没有指定要在其中查找
filtering_streambuf
、input
或gzip_decompressor
的命名空间。尝试:
示例 不这样做的原因这是因为简介中建立的约定:
The problem is that you are not specifying the namespace in which to look up
filtering_streambuf
,input
, orgzip_decompressor
.Try:
The reason that the example does not do this is because of the convention established in the introduction: