protected virtual member function
<streambuf> <iostream>

std::streambuf::pbackfail

int pbackfail (int c = EOF);
Put character back in the case of backup underflow
Virtual function called by other member functions to put a character back into the controlled input sequence and decrease the position indicator.

It shall only be called (as public member functions sungetc and sputbackc do) either when there are no putback positions available at the get pointer (gptr), or when the character being put back does not match the one in the buffer.

Its default behavior in streambuf is to always return EOF (indicating failure), but derived classes can override this behavior to modify the gptr and egptr internal pointers in such a way that more characters from the input sequence may be made accessible through the buffer (if these are available). Both filebuf and stringbuf override this virtual member function.

Parameters

c
Character to be put back, or the end-of-file value (EOF) to keep the value of the character at the putback position.
It is unspecified whether the content of the controlled input sequence is modified if the function succeeds and c does not match the character at that position.

Return Value

On success, the value of the character put back, converted to a value of type int.
The function returns the end-of-file value (EOF) on failure.

Data races

Modifies the stream buffer object.
Concurrent access to the same stream buffer object may introduce data races.

Exception safety

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

See also