boost :: iostream :: filtering_streambuf的编译错误 [英] compile error for boost::iostream::filtering_streambuf
问题描述
下面的代码可以得到下面的编译错误。
p>in.push(uncompressed_string);
错误6错误C2027:使用未定义类型'boost :: STATIC_ASSERTION_FAILURE' c:\program files(x86)\boost\boost_1_47\boost\iostreams\chain.hpp 488 1代理
boost :: iostreams :: filtering_streambuf& boost :: iostreams :: input>在;
ostringstream uncompressed_string;
ostringstream compressed_string;
uncompressed_string<< f
in.push(boost :: iostreams :: bzip2_compressor());
in.push(uncompressed_string);
boost :: iostreams :: copy(uncompressed_string,compressed_string);
错误是由于推送一个 过滤流作为其设备。
#include< sstream> ;
#include< string>
//#include< boost / iostreams / filtering_stream.hpp>
#include< boost / iostreams / filtering_streambuf.hpp>
#include< boost / iostreams / filter / bzip2.hpp>
#include< boost / iostreams / copy.hpp>
int main()
{
std :: string buf =this is a test\\\
;
// boost :: iostreams :: filtering_istream in; //我认为这更简单
boost :: iostreams :: filtering_streambuf& boost :: iostreams :: input>在;
in.push(boost :: iostreams :: bzip2_compressor());
std :: istringstream uncompressed_string(buf);
// in.push(boost :: make_iterator_range(buf)); //另一个选项
in.push(uncompressed_string);
std :: ostringstream compressed_string;
boost :: iostreams :: copy(in,compressed_string);
std :: cout<< compressed_string.str();
}
使用gcc 4.6.1和boost 1.46测试
〜$ ./test | bzcat
这是一个测试
Just trying to compress a string with bzip2 so that I can send it over a pipe with ReadFile.
The following line earns me the following compile error.
in.push(uncompressed_string);
Error 6 error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE' c:\program files (x86)\boost\boost_1_47\boost\iostreams\chain.hpp 488 1 Agent
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
ostringstream uncompressed_string;
ostringstream compressed_string;
uncompressed_string << buf;
in.push(boost::iostreams::bzip2_compressor());
in.push(uncompressed_string);
boost::iostreams::copy(uncompressed_string, compressed_string);
The error was due to pushing an output stream into an input filtering stream as its Device.
#include <sstream>
#include <string>
//#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/copy.hpp>
int main()
{
std::string buf = "this is a test\n";
//boost::iostreams::filtering_istream in; // I think this is simpler
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
in.push(boost::iostreams::bzip2_compressor());
std::istringstream uncompressed_string(buf);
// in.push(boost::make_iterator_range(buf)); // another option
in.push(uncompressed_string);
std::ostringstream compressed_string;
boost::iostreams::copy(in, compressed_string);
std::cout << compressed_string.str();
}
tested with gcc 4.6.1 and boost 1.46
~ $ ./test | bzcat
this is a test
这篇关于boost :: iostream :: filtering_streambuf的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!