My understanding of 27.8.2.4-11 is that, regardless of by how much
std::stringbuf::seekoff is requested to move 'gptr', it should fail, in
particular, if (quoting):
"newoff + off refers to an uninitialized character (as defined in 27.8.2.3
paragraph 1)"
for ios_base::cur operation and ios_base::in openmode, newoff == gnext - gbeg
that is 1 in my example.
off is 0, so newoff + off is 1. I believe that newoff + off refers to
uninitialized characters because, as defined in 27.8.2.3. Quoting:
"If the basic_stringbuf was created only in input mode, the resultant
basic_string contains the character sequence in the range [eback(),egptr())"
Note that the character at egptr() is excluded. As for egptr(), it is equal to
eback() + s.size() as per 27.8.2.3-3 which applies because the initializing
effect of the constructor used in my example is that of calling str(const
string&), as per 27.8.2.1-3. That is, in my example, egptr() == eback() + 1.
As we established that the positioning operation should fail,
stringbuf::seekoff should return pos_type(off_type(-1)) as per 27.8.2.4-11.
What am I missing?
-Pavel