This protected virtual function is called by the public functions basic_streambuf::sungetc and basic_streambuf::sputbackc (which, in turn, are called by basic_istream::unget and basic_istream::putback).
1)The caller is requesting that the get area is backed up by one character (
pbackfail()
is called with no arguments or with
EOFas the argument)
a) First, checks if there is a putback position, and if there really isn't, fails (strstreambuf
has no external character source to re-read).
If the caller was wrong and the putback position is in fact available, simply decrements
basic_streambuf::gptr(), e.g. by calling
gbump(-1).
2) The caller attempts to putback a different character from the one retrieved earlier (pbackfail()
is called with the character that needs to be put back), in which case
a) First, checks if there is a putback position, and if there isn't, fails.
b)Then checks what character is in the putback position. If the character held there is already equal to
(char)c, then simply decrements
basic_streambuf::gptr().
c) Otherwise, if the buffer is unmodifiable (this strstreambuf was constructed with a string literal or some other const array), fails.
[edit] Parameters c - the character to put back, or Traits::eof() to indicate that backing up of the get area is requested [edit] Return valuec on success except if c was EOF, in which case unspecified value other than EOF is returned.
EOF on failure.
[edit] Example [edit] See also puts a character back into the input sequence, possibly modifying the input sequencestd::basic_streambuf<CharT,Traits>
) [edit] moves the next pointer in the input sequence back by one
std::basic_streambuf<CharT,Traits>
) [edit] puts one character back in the input sequence
std::basic_streambuf<CharT,Traits>
) [edit] unextracts a character
std::basic_istream<CharT,Traits>
) [edit] puts a character into input stream
std::basic_istream<CharT,Traits>
) [edit]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4