Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::basic_stringbuf<CharT,Traits,Allocator>::pbackfail

      From cppreference.com
      <cpp‎ |io‎ |basic stringbuf
       
       
       
       
      protected:
      virtual int_type pbackfail( int_type c= Traits::eof())

      This protected virtual function is called by the public functionsbasic_streambuf::sungetc andbasic_streambuf::sputbackc (which, in turn, are called bybasic_istream::unget andbasic_istream::putback).

      1) 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. (stringbuf has no external character source to re-read)
      b) If the caller was wrong and the putback position is in fact available, simply decrementsbasic_streambuf::gptr(), e.g. by callinggbump(-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 toc, 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::out is nonzero), then decrementsbasic_streambuf::gptr() and writesc to the location pointed to gptr() after adjustment.

      Contents

      [edit]Parameters

      c - the character to put back, or Traits::eof() to indicate that backing up of the get area is requested

      [edit]Return value

      c on success except ifc wasTraits::eof(), in which caseTraits::not_eof(c) is returned.

      Traits::eof() on failure.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      [virtual]
      puts a character back into the input sequence, possibly modifying the input sequence
      (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)[edit]
      moves the next pointer in the input sequence back by one
      (public member function ofstd::basic_streambuf<CharT,Traits>)[edit]
      puts one character back in the input sequence
      (public member function ofstd::basic_streambuf<CharT,Traits>)[edit]
      unextracts a character
      (public member function ofstd::basic_istream<CharT,Traits>)[edit]
      puts a character into input stream
      (public member function ofstd::basic_istream<CharT,Traits>)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_stringbuf/pbackfail&oldid=105212"

      [8]ページ先頭

      ©2009-2025 Movatter.jp