std::basic_...f::pbackfail(3)
π NAME π
okay so this page is std::basic_...f::pbackfail(3) in the C++ Standard Libary manual β yes, that spelling is what the manual says, weβre not fixing it, weβre just folding it in here like a cute lil sticky note π«Ά. The actual main character is std::basic_stringbuf::pbackfail, and the NAME line is literally std::basic_stringbuf::pbackfail β std::basic_stringbuf::pbackfail, periodt π
.
π¦ Synopsis π¦
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).
protected:
virtual int_type pbackfail( int_type c = Traits::eof() )
- The caller is requesting that the get area is backed up by one character (
pbackfail()is called with no arguments or withTraits::eof()as the argument).- a) First, checks if there is a putback position, and if there really isnβt, fails. (
stringbufhas no external character source to re-read.) - b) If the caller was wrong and the putback position is in fact available, simply decrements
basic_streambuf::gptr(), e.g. by callinggbump(-1).
- a) First, checks if there is a putback position, and if there really isnβt, fails. (
- 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
c, as determined byTraits::eq(to_char_type(c), gptr()[-1]), then simply decrementsbasic_streambuf::gptr(). - c) Otherwise, if the buffer is open for reading only, fails.
- d) Otherwise, if the buffer is open for writing (
mode && std::ios_base::outis nonzero), then decrementsbasic_streambuf::gptr()and writescto the location pointed togptr()after adjustment.
π Parameters π
cβ the character to put back, orTraits::eof()to indicate that backing up of the get area is requested.
π Return value π
con success, except ifcwasTraits::eof(), in which caseTraits::not_eof(c)is returned.Traits::eof()on failure.
π Example π
This section is incomplete Reason: no example
π₯ See also π₯
pbackfailβ puts a character back into the input sequence, possibly modifying the input sequence.[virtual](virtual protected member function ofstd::basic_streambuf<CharT,Traits>)sungetcβ moves the next pointer in the input sequence back by one (public member function ofstd::basic_streambuf<CharT,Traits>)sputbackcβ puts one character back in the input sequence (public member function ofstd::basic_streambuf<CharT,Traits>)ungetβ unextracts a character (public member function ofstd::basic_istream<CharT,Traits>)putbackβ puts a character into input stream (public member function ofstd::basic_istream<CharT,Traits>)
π·οΈ Category π·οΈ
- Todo β no example
source/version/date cuteness: http://cppreference.com Β· 2024.06.10 β bye bestie, slay your buffers π
π«Ά
π¦ 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