27.6.3.4.2 Buffer management and positioning
pos_type seekoff(off_type off, ios_base::seekdir way, ios_base::openmode which = ios_base::in | ios_base::out);
- Effects: Alters the stream positions within one or more of the controlled sequences in a way that is defined separately for each class derived from
basic_streambuf
in this Clause (27.8.2.4, 27.9.1.5).- Default behavior: Returns
pos_type(off_type(-1))
.
So far, so good. The basic_streambuf
derivation I'm using can alter its position separately for ios_base::in
and/or ios_base::out
. But, what do I need to return when both are specified?
If you specify ios_base::in
or ios_base::out
, we would return new stream position of the specific sequence.
It is a bit up to your stream to define what happens. The built in streams differ, in that some can have separate read and write positions (stringstream) while others just have one (fstream).
If the user does a reposition and specify both in and out, perhaps you should move both. If it is a seek with a zero offset to get the current position, it is not unreasonable to fail if the positions differ.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With