1
下面的代碼片段可以用字符串編譯,但不能用<wstring>
編譯。使用gzip_compressor和boost :: iostreams :: filtering_wostream,編譯器錯誤
我以前filtering_ostream
與<string>
const void X::Compress(const wstring& data)
{
wstring compressedString;
boost::iostreams::filtering_wostream compressingStream;
compressingStream.push(boost::iostreams::gzip_compressor(boost::iostreams::gzip_params(boost::iostreams::gzip::best_compression)));
compressingStream.push(boost::iostreams::back_inserter(compressedString));
compressingStream << data;
boost::iostreams::close(compressingStream);
//...
}
編譯錯誤:
\boost_x64/boost/iostreams/chain.hpp:258:9: error: no matching function for call to std::list<boost::iostreams::detail::linked_streambuf<wchar_t, std::char_traits<wchar_t> >*,
std::allocator<boost::iostreams::detail::linked_streambuf<wchar_t, std::char_traits<wchar_t> >*> >::push_backn(std::auto_ptr<boost::iostreams::stream_buffer<boost::iostreams::basic_gzip_compressor<>, std::char_traits<wchar_t>, std::allocator<wchar_t>, boost::iostreams::output> >::element_type*)
list().push_back(buf.get());
^
的gzip預計'char'流。你或許可以用codecvt的事實來實現某些東西,但坦率地說,我沒有那麼方便。然後我會+1 – sehe 2014-09-19 17:09:07