I/O manipulators | ||||
Print functions(C++23) | ||||
C-style I/O | ||||
Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
Streams | ||||
Abstractions | ||||
File I/O | ||||
String I/O | ||||
Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
Synchronized Output | ||||
(C++20) | ||||
Types | ||||
Error category interface | ||||
(C++11) | ||||
(C++11) |
|
|
protected: virtual int_type pbackfail( int_type c= Traits::eof()); | ||
This function can only be called if any of the following condition is satisfied:
This function is called by the public functionssungetc() andsputbackc() (which, in turn, are called bybasic_istream::unget andbasic_istream::putback) when either:
pbackfail()
is called with no arguments). In this situation, the purpose ofpbackfail()
is to back up the get area by one character, if the associated character sequence allows this (e.g. a file-backed streambuf may reload the buffer from a file, starting one character earlier).pbackfail()
is called with the character that needs to be put back). In this situation, the purpose ofpbackfail()
is to place the characterc
into the get area at the position just beforebasic_streambuf::gptr(), and, if possible, to modify the associated character sequence to reflect this change. This may involve backing up the get area as in the first variant.The default base class version of this function does nothing and returnsTraits::eof() in all situations. This function is overridden by the derived classes:basic_stringbuf::pbackfail,basic_filebuf::pbackfail,strstreambuf::pbackfail, and is expected to be overridden by user-defined and third-party library stream classes.
Contents |
ch | - | character to put back orTraits::eof() if only back out is requested |
Traits::eof() in case of failure, some other value to indicate success. The base class version always fails.
This section is incomplete Reason: no example |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 32 | C++98 | the calling condition 'traits::eq(*gptr(),traits::to_char_type(c)) returnsfalse' did not match the description ofsputbackc() | corrected to match the description |
[virtual] | backs out the input sequence to unget a character, not affecting the associated file (virtual protected member function of std::basic_filebuf<CharT,Traits> )[edit] |
[virtual] | puts a character back into the input sequence (virtual protected member function of std::basic_stringbuf<CharT,Traits,Allocator> )[edit] |
[virtual] | backs out the input sequence to unget a character (virtual protected member function of std::strstreambuf )[edit] |
moves the next pointer in the input sequence back by one (public member function)[edit] | |
puts one character back in the input sequence (public member function)[edit] |