31 Input/output library [input.output]

31.6 Stream buffers [stream.buffers]

31.6.3 Class template basic_streambuf [streambuf] Virtual functions [streambuf.virtuals] Putback [streambuf.virt.pback]

int_type pbackfail(int_type c = traits::eof());
The pending sequence is defined as for underflow(), with the modifications that
  • If traits​::​eq_int_type(c, traits​::​eof()) returns true, then the input sequence is backed up one character before the pending sequence is determined.
  • If traits​::​eq_int_type(c, traits​::​eof()) returns false, then c is prepended.
    Whether the input sequence is backed up or modified in any other way is unspecified.
Postconditions: On return, the constraints of gptr(), eback(), and pptr() are the same as for underflow().
Returns: traits​::​eof() to indicate failure.
Failure may occur because the input sequence could not be backed up, or if for some other reason the pointers cannot be set consistent with the constraints.
pbackfail() is called only when put back has really failed.
Returns some value other than traits​::​eof() to indicate success.
Default behavior: Returns traits​::​eof().
Remarks: The public functions of basic_streambuf call this virtual function only when gptr() is null, gptr() == eback(), or traits​::​eq(traits​::​to_char_type(c), gptr()[-1]) returns false.
Other calls shall also satisfy that constraint.