Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      C++ named requirements:UnformattedInputFunction

      From cppreference.com
      <cpp‎ |named req
       
       
      C++ named requirements
       

      [edit]Requirements

      AnUnformattedInputFunction is a stream input function that performs the following:

      1) Constructs an object of typebasic_istream::sentry with automatic storage duration and with thenoskipws argument set totrue, which performs the following:
      • Ifeofbit orbadbit are set on the input stream, sets thefailbit as well, and if exceptions onfailbit are enabled in this input stream'sexception mask ((exceptions()& failbit)!=0), throwsios_base::failure.
      • Flushes the tie()'d output stream, if applicable.
      2) Checks the status of the sentry by callingsentry::operator bool(), which is equivalent tobasic_ios::good.
      • If the operator returnsfalse or sentry's constructor throws an exception:
      • Sets the number of extracted characters (gcount) in the input stream to zero.
      • If the function was called to write to an array ofCharT, writesCharT() (the null character) to the first location of the array.
      • If the operator returnstrue, performs the input as if by callingrdbuf()->sbumpc() orrdbuf()->sgetc().
      • If the end of the stream is reached (the call tordbuf()->sbumpc() orrdbuf()->sgetc() returnsTraits::eof()), setseofbit. If exceptions oneofbit are enabled in this stream'sexception mask ((exceptions()& eofbit)!=0), throwsios_base::failure.
      • If an exception is thrown during input, setsbadbit in the input stream. If exceptions onbadbit are enabled in this stream'sexception mask ((exceptions()& badbit)!=0), the exception is also rethrown.
      • If no exception was thrown during input, sets the number of extracted characters (gcount) in the input stream.
      3) In any event, whether terminating by exception or returning, the sentry's destructor is called before leaving this function.

      [edit]Standard library

      The following standard library functions areUnformattedInputFunctions.

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 61C++98it was unclear whether throwing an exception because of
      settingeofbit and/orfailbit will result in settingbadbit
      exceptions thrown frombasic_ios::clear
      are not caught or rethrown
      LWG 160C++98the process of determining whether the exception caught
      is rethrown mentioned a non-existing functionexception()
      corrected toexceptions()
      LWG 243C++98the behavior whensentry::operator bool() returnsfalse
      or the sentry object fails to be constructed was not specified
      specified
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/UnformattedInputFunction&oldid=144416"

      [8]ページ先頭

      ©2009-2025 Movatter.jp