Not a duplicate of C++: Wrapping vector<char> with istream
Those solutions either use boost (which is not available) or do not work with seekg
on the stream. C++11 is also not available.
rdbuf()->pubsetbuf
method on a stringstream is not guaranteed to work and does not on VS2015.
Given a std::vector<char>
, how can I create some object compatible with std::istream
which reads the data directly from the vector without copying it (as stringstream would do)?
I need to make use of the seekg
function on the stream object.
My attempts so far have failed or only worked on some compilers, so I am looking for the correct answer from someone who knows all the pitfalls of C++ streams.