2286. stringbuf::underflow() underspecified

Section: 30.8.2.4 [stringbuf.virtuals] Status: New Submitter: Sergey Zubkov Opened: 2013-08-29 Last modified: 2016-02-10

Priority: 4

View all other issues in [stringbuf.virtuals].

View all issues with New status.

Discussion:

In 30.8.2.4 [stringbuf.virtuals]/1, basic_stringbuf::underflow() is specified to unconditionally return traits::eof() when a read position is not available.

The semantics of basic_stringbuf require, and existing libraries implement it so that this function makes a read position available if possible to do so, e.g. if some characters were inserted into the stream since the last call to overflow(), resulting in pptr() > egptr(). Compare to the conceptually similar D.7.1.3 [depr.strstreambuf.virtuals]/15.

Proposed resolution:

This wording is relative to N3691.

  1. Change 30.8.2.4 [stringbuf.virtuals] as indicated:

    int_type underflow();
    

    -1- Returns: If the input sequence has a read position available or the function makes a read position available (as described below), returns traits::to_int_type(*gptr()). Otherwise, returns traits::eof(). Any character in the underlying buffer which has been initialized is considered to be part of the input sequence.

    -?- The function can make a read position available only if (mode & ios_base::in) != 0 and if the write next pointer pptr() is not null and is greater than the current read end pointer egptr(). To make a read position available, the function alters the read end pointer egptr() to equal pptr().