I am having trouble with typedef'ing a custom bzip2_compressor that
works with unsigned char instead of plain char. This is the pipeline:
typedef boost::uint8_t uint8
typedef boost::iostreams::filtering_stream<
boost::iostreams::input, uint8> filtering_istream;
typedef boost::iostreams::filtering_stream<
boost::iostreams::output, uint8> filtering_ostream;
typedef boost::iostreams::basic_bzip2_compressor<
std::allocator<uint8>> bzip2_compressor;
// FIXME: The bzip2_compressor as defined above does not fit in
// the pipeline, what is the correct way to typedef it?
std::vector<uint8> raw;
auto range = boost::make_iterator_range(start, end); // args of type uint8*.
filtering_istream in(range);
filtering_ostream out;
-> out.push(bzip2_compressor());
out.push(boost::iostreams::back_inserter(raw));
boost::iostreams::copy(in, out);
The line with the arrow causes the following errors below, presumable
due to an incorrect typedef of the basic_bzip2_compressor. I could not
find the correct way to typedef it by crawling through the bzip2.hpp
header file of the iostreams library. Any ideas? I am using g++ 4.6 with
-std=gnu++0x for C++0x support.
Matthias
Error subset:
[..]
../boost/iostreams/chain.hpp:258: error: no matching function for call to 'std::list*, std::allocator*> >::push_back(std::auto_ptr, std::char_traits<unsigned char>, std::allocator<unsigned char>, boost::iostreams::output> >::element_type*)'
[..]
/opt/local/include/gcc46/c++/bits/streambuf.tcc:89: error: invalid conversion from 'std::basic_streambuf::char_type*' to '__gnu_cxx::char_traits<unsigned char>::char_type*' [-fpermissive]
/opt/local/include/gcc46/c++/bits/char_traits.h:188: error: initializing argument 1 of 'static __gnu_cxx::char_traits<_CharT>::char_type* __gnu_cxx::char_traits<_CharT>::copy(__gnu_cxx::char_traits<_CharT>::char_type*, const char_type*, std::size_t) [with _CharT = unsigned char, __gnu_cxx::char_traits<_CharT>::char_type = unsigned char, std::size_t = long unsigned int]' [-fpermissive]
/opt/local/include/gcc46/c++/bits/streambuf.tcc:89: error: invalid conversion from 'const char_type*' to 'const char_type*' [-fpermissive]
/opt/local/include/gcc46/c++/bits/char_traits.h:188: error: initializing argument 2 of 'static __gnu_cxx::char_traits<_CharT>::char_type* __gnu_cxx::char_traits<_CharT>::copy(__gnu_cxx::char_traits<_CharT>::char_type*, const char_type*, std::size_t) [with _CharT = unsigned char, __gnu_cxx::char_traits<_CharT>::char_type = unsigned char, std::size_t = long unsigned int]' [-fpermissive]
/opt/local/include/gcc46/c++/bits/streambuf.tcc: In member function 'std::streamsize std::basic_streambuf<_CharT, _Traits>::xsgetn(std::basic_streambuf<_CharT, _Traits>::char_type*, std::streamsize) [with _CharT = char, _Traits = std::char_traits<unsigned char>, std::streamsize = long int, std::basic_streambuf<_CharT, _Traits>::char_type = char]':
[..]
.._client.cc:170: instantiated from here
/opt/local/include/gcc46/c++/bits/streambuf.tcc:55: error: invalid conversion from 'std::basic_streambuf::char_type*' to '__gnu_cxx::char_traits<unsigned char>::char_type*' [-fpermissive]
/opt/local/include/gcc46/c++/bits/char_traits.h:188: error: initializing argument 1 of 'static __gnu_cxx::char_traits<_CharT>::char_type* __gnu_cxx::char_traits<_CharT>::copy(__gnu_cxx::char_traits<_CharT>::char_type*, const char_type*, std::size_t) [with _CharT = unsigned char, __gnu_cxx::char_traits<_CharT>::char_type = unsigned char, std::size_t = long unsigned int]' [-fpermissive]
/opt/local/include/gcc46/c++/bits/streambuf.tcc:55: error: invalid conversion from 'std::basic_streambuf::char_type*' to 'const char_type*' [-fpermissive]
/opt/local/include/gcc46/c++/bits/char_traits.h:188: error: initializing argument 2 of 'static __gnu_cxx::char_traits<_CharT>::char_type* __gnu_cxx::char_traits<_CharT>::copy(__gnu_cxx::char_traits<_CharT>::char_type*, const char_type*, std::size_t) [with _CharT = unsigned char, __gnu_cxx::char_traits<_CharT>::char_type = unsigned char, std::size_t = long unsigned int]' [-fpermissive]