[iostreams] tellg not supported on devices / filters that aren't seekable
I find it inconvenient that tellg isn't supported on filters / devices that isn't seekable, since tellg doesn't really seek but simply reports the current read head position. Here follows some example code that will throw due to this: #include <ostream> #include "boost/iostreams/categories.hpp" #include "boost/iostreams/filtering_stream.hpp" #include "boost/iostreams/filter/zlib.hpp" int main() { boost::iostreams::filtering_stream< boost::iostreams::input > strm( ( boost::iostreams::zlib_decompressor() ) ); char sourceArr[512]; strm.push( boost::iostreams::array_source( sourceArr, sourceArr + sizeof( sourceArr ) ) ); strm.tellg(); } The problem is that, at least on windows, and I assume other platforms due to the somewhat lackluster interface of stream_buf, is implemented in terms of pubseekoff( 0, ios_base::cur, ios_base::in ). This call doesn't really alter the read head and should in this instance be supported, but isn't.
participants (1)
-
Sebastian Karlsson