std::basic_...f::pbackfail(3)
π NAME π
Okay bestie, this is the std::basic_...f::pbackfail(3) page from the C++ Standard Libary manual π«Ά. Name check: std::basic_streambuf::pbackfail β and yeah, thatβs std::basic_streambuf::pbackfail again. The page said it twice and honestly? Committed to the bit π
.
β¨ Synopsis β¨
protected:
virtual int_type pbackfail( int_type c = Traits::eof() );
This function can only be called if any of the following condition is satisfied:
gptr()is null,gptr() == eback(), ortraits::eq(traits::to_char_type(c), gptr()[-1])returns false.
This function is called by the public functions sungetc() and sputbackc() (which, in turn, are called by basic_istream::unget and basic_istream::putback) when either:
- There is no putback position in the get area (
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). - 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 this situation, the purpose ofpbackfail()is to place the charactercinto 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 returns Traits::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.
π Parameters π
chβ character to put back orTraits::eof()if only back out is requested.
π Return value π
Traits::eof()in case of failure.- some other value to indicate success.
The base class version always fails.
π¦ Example π¦
This section is incomplete. Reason: no example.
π₯ Defect reports π₯
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR
LWG 32β applied toC++98. Behavior as published: the calling condition'traits::eq(*gptr(),traits::to_char_type(c)) returns false'did not match the description ofsputbackc(). Correct behavior: the calling condition corrected to match the description ofsputbackc().
π See also π
pbackfailβ backs out the input sequence to unget a character, not affecting the associated file;[virtual](virtual protected member function ofstd::basic_filebuf<CharT,Traits>).pbackfailβ puts a character back into the input sequence;[virtual](virtual protected member function ofstd::basic_stringbuf<CharT,Traits,Allocator>).pbackfailβ backs out the input sequence to unget a character;[virtual](virtual protected member function ofstd::strstreambuf).sungetcβ moves the next pointer in the input sequence back by one (public member function).sputbackcβ puts one character back in the input sequence (public member function).
π Category π
Todo no example
Thatβs the whole page, bestie π. Source/version and date: http://cppreference.com and 2024.06.10 β this was std::basic_...f::pbackfail(3), signing off with a little sparkle β¨π
.
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms