169. Bad efficiency of overflow() mandated

Section: 30.8.2.4 [stringbuf.virtuals] Status: TC1 Submitter: Dietmar Kühl Opened: 1999-07-20 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [stringbuf.virtuals].

View all issues with TC1 status.

Discussion:

Paragraph 8, Notes, of this section seems to mandate an extremely inefficient way of buffer handling for basic_stringbuf, especially in view of the restriction that basic_ostream member functions are not allowed to use xsputn() (see 30.7.5.1 [ostream]): For each character to be inserted, a new buffer is to be created.

Of course, the resolution below requires some handling of simultaneous input and output since it is no longer possible to update egptr() whenever epptr() is changed. A possible solution is to handle this in underflow().

Proposed resolution:

In 30.8.2.4 [stringbuf.virtuals] paragraph 8, Notes, insert the words "at least" as in the following:

To make a write position available, the function reallocates (or initially allocates) an array object with a sufficient number of elements to hold the current array object (if any), plus at least one additional write position.