protected virtual member function


int overflow (int c = EOF);
Put character
Writes c to the current position of the put pointer (pptr), and advances that pointer one position forward.

If there are no positions available and the stringbuf object was constructed with ios_base::out, the function first attempts to make more write positions available, reallocating the internal buffer if necessary: this may modify the pointers to both the input and output controlled sequences (up to all six of eback, gptr, egptr, pbase, pptr, epptr).

The function may also reallocate the buffer to make it larger on any call to this function, even if there are still write positions available (although it is not required to).

If c is EOF, no characters are written and the put pointer (pptr) is not advanced, but the function may still reallocate as described above (although it is not required to).

This virtual function is called by public member functions such as sputc to put a character when there are no writing positions available at the put pointer (pptr).


Character to write.
If this is EOF, no characters are written and the put pointer (pptr) is not advanced, but other effects may apply.

Return Value

In case of success, a value other than EOF is returned: If character c was successfully written, c is returned.
Otherwise, it returns EOF to signal failure.

Data races

Modifies the stringbuf object.
Concurrent access to the same object may cause data races.

Exception safety

Basic guarantee: if an exception is thrown, the object is in a valid state.

See also