I have this stream that performs decompression using Boost.Iostreams:
struct istream_zlib
: public boost::iostreams::filtering_stream<boost::iostreams::input, char>
{
istream_zlib(std::istream& in)
{
push(boost::iostreams::zlib_decompressor());
push(in);
}
};
Now, I would like to access the underlying stream (std::istream& in) later on. Naively, I thought that requesting a std::istream through component() would do it, but the pointer I get back is null:
auto ptr = component<std::istream>(1); // ptr is null!
What type should I provide to component() for doing that?
It's not real, since not
istreamwill be pushed intofiltering_stream(for my boost 1.48 it will beboost::iostreams::detail::mode_adapter<boost::iostreams::input, std::istream>for example), you can check it type bycomponent_typefunction. However, I have no ideas, why you need to getstreamfromfiltering_stream, since you send reference - you should have this object in places, where you use thisfiltering_stream.Also, you can use
reference_wrapperfor this case (i.epush(boost::ref(in));) and then get it by component using