हैलो मैं Boost.IOstreams का उपयोग कर bzip2 फाइल करने के लिए में अपने डेटा स्टोर करने के लिए चाहते हैं हूँ।BOOST.IOstreams: मुसीबत bzip2
void test_bzip()
{
namespace BI = boost::iostreams;
{
string fname="test.bz2";
{
BI::filtering_stream<BI::bidirectional> my_filter;
my_filter.push(BI::combine(BI::bzip2_decompressor(), BI::bzip2_compressor())) ;
my_filter.push(std::fstream(fname.c_str(), std::ios::binary|std::ios::out)) ;
my_filter << "test" ;
}//when my_filter is destroyed it is trowing an assertion.
}
};
मैं क्या गलत कर रहा हूं? मैं बूस्ट 1.42.0 का उपयोग कर रहा हूं।
तरह अरमान संबंध है।
#include <fstream>
#include <iostream>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <string>
void test_bzip()
{
namespace BI = boost::iostreams;
{
std::string fname="test.bz2";
{
std::fstream myfile(fname.c_str(), std::ios::binary|std::ios::out);
BI::filtering_stream<BI::output> my_filter;
my_filter.push(BI::bzip2_compressor()) ;
//my_filter.push(std::fstream(fname.c_str(), std::ios::binary|std::ios::out)) ; //this line will work on VC++ 2008 V9 but not in G++ 4.4.4
my_filter.push(myfile);
my_filter << "test";
}
}
};
शायद कुछ एक क्यों की व्याख्या कर सकते: अगर मैं द्विदिश विकल्प को दूर
संपादित कोड काम कर रहा है?
दूसरा टुकड़ा भी जीसीसी के साथ संकलन नहीं है। my_filter.push (std :: fstream (...)) 'कोई मिलान करने वाला फ़ंक्शन' –
@epronk: यह किस कंपाइलर है? मैं जीसीसी 4.4.4 का उपयोग करता हूं: g ++ bz_test.cpp -I $ {BOOSTROOT}/include -L $ {BOOSTROOT}/lib -lboost_iostreams और यह बिना किसी समस्या के संकलित करता है। मैंने अभी पोस्ट संपादित किया है। – Arman
क्या आपने इसे हल किया? यदि ऐसा है तो कृपया एक उत्तर पोस्ट करें। – Cookie