protected virtual member function
<streambuf>
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
- streambuf::sputbackc
- Put character back (public member function)
- streambuf::underflow
- Get character in the case of underflow (protected virtual member function)