protected virtual member function
<streambuf> <iostream>

std::basic_streambuf::pbackfail

int_type pbackfail (int_type c = traits_type::eof());
Put character back on 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 basic_streambuf is to always return traits_type::eof() (indicating failure), but derived classes can override this behavior to modify the buffer or the gptr and egptr internal pointers to accommodate for the put-back request, if supported. Both basic_filebuf and basic_stringbuf override this virtual member function (see basic_filebuf::pbackfail and basic_stringbuf::pbackfail).

Parameters

c
Character to be put back, or the end-of-file value (traits_type::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.
Member type int_type is an integral type able to represent any character value or the special end-of-file value.

Return Value

On success, the value of the character put back, converted to a value of type int_type using member traits_type::to_int_type.
The function returns the end-of-file value (traits_type::eof()) on failure.
Member type int_type is an integral type able to represent any character value or the special end-of-file value.

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