Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
IOstream Library
manipulators
classes:
filebuf
fstream
ifstream
ios
iostream
ios_base
istream
istringstream
ofstream
ostream
ostringstream
streambuf
stringbuf
stringstream
objects:
cerr
cin
clog
cout
types:
fpos
streamoff
streampos
streamsize
streambuf
streambuf::streambuf
streambuf::~streambuf
public members:
streambuf::getloc
streambuf::in_avail
streambuf::pubimbue
streambuf::pubseekoff
streambuf::pubseekpos
streambuf::pubsetbuf
streambuf::pubsync
streambuf::sbumpc
streambuf::sgetc
streambuf::sgetn
streambuf::snextc
streambuf::sputbackc
streambuf::sputc
streambuf::sputn
streambuf::sungetc
protected members:
streambuf::eback
streambuf::egptr
streambuf::epptr
streambuf::gbump
streambuf::gptr
streambuf::pbase
streambuf::pbump
streambuf::pptr
streambuf::setg
streambuf::setp
virtual prot. members:
streambuf::imbue
streambuf::overflow
streambuf::pbackfail
streambuf::seekoff
streambuf::seekpos
streambuf::setbuf
streambuf::showmanyc
streambuf::sync
streambuf::uflow
streambuf::underflow
streambuf::xsgetn
streambuf::xsputn


streambuf::pbackfail

virtual protected member function
int pbackfail ( int c = EOF );

Put character back in the case of backup underflow

This virtual member function is called under two circumstances:
- When a character is to be put back by either sputbackc or sungetc, but there are no putback positions available (i.e., the get pointer gptr points to the same location as the beginning pointer eback, indicating that the get pointer is at the beginning of the internal input array).
- Or when, even though there are putback positions available, the character passed as argument to sputbackc does not match the character at the putback position.

This function is expected to modify the pointer that define the internal input array (eback, gptr and egptr) in such a way that if there are more characters available in the controlled backup input sequence at the location right before the beginning pointer eback, at least some of them are made available through this internal input array.

If at least one putback position is successfuly made available, the get pointer is then decreased by one. Otherwise, when there are no more characters available in the controlled input backup sequence before the one represented by gptr, the function returns EOF (or traits::eof() for other traits) to signal the failure.

When the parameter c is EOF (or traits::eof() for other traits) the get pointer is decreased by one but the existing character at the putback position is not modified in any way. For any other value of c, each particular implementation may determine whether the content of the input sequence is permanently modified or not when c does not match the character at that position.

This is a virtual member function that can be overriden for a specific behavior in derived classes. The default behavior of this function in streambuf is to do nothing and return EOF (or traits::eof() for other traits).

Both standard derived classes, filebuf and stringbuf override this member function (see filebuf::pbackfail and stringbuf::pbackfail).


Parameters

c
Character to be put back, or EOF (or traits::eof() for other traits) to keep the existing character at that position.

Return Value

If the function was successful, the function returns a value different from EOF (or traits::eof() for other traits).
Otherwise, it returns EOF (or traits::eof() for other traits).

Basic template member declaration

( basic_streambuf<charT,traits> )
1
2
typedef traits::int_type int_type;
int_type pbackfail ( int_type c = traits::eof() );


See also