tellg and seekg not working when wrap vector<char> in istream

4063 views c++

As this link [] said:

I use setg(,, + vec.size()); to initialize a streambuf. After that, read() on istream working properly, but tellg() always return -1, and seekg() always failed.

anyone can help?

answered question

1 Answer


seekg and tellg ask the streambuf via pubseekoff and pubseekpos to actually perform the work. The default implementation of these functions simply fail.

You need to implement seekoff and seekpos in your streambuf.

posted this

Have an answer?


Please login first before posting an answer.