Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ios_base::iostate

      From cppreference.com
      <cpp‎ |io‎ |ios base
       
       
       
       
      typedef/*implementation defined*/ iostate;
      staticconstexpr iostate goodbit=0;
      staticconstexpr iostate badbit  =/* implementation defined */

      staticconstexpr iostate failbit=/* implementation defined */

      staticconstexpr iostate eofbit  =/* implementation defined */

      Specifies stream state flags. It is aBitmaskType, the following constants are defined:

      Constant Explanation
      goodbit no error
      badbit irrecoverable stream error
      failbit input/output operation failed (formatting or extraction error)
      eofbit associated input sequence has reached end-of-file

      Contents

      [edit]The eofbit

      The eofbit is set by the following standard library functions:

      • The string input functionstd::getline if it completes by reaching the end of the stream, as opposed to reaching the specified terminating character.
      • The numeric input overloads ofbasic_istream::operator>> if the end of the stream was encountered while reading the next character, on Stage 2 ofnum_get::get processing. Depending on the parsing state,failbit may or may not be set at the same time: for example,int n; istringstream buf("1"); buf>> n; setseofbit, but notfailbit: the integer1 was successfully parsed and stored inn. On the other hand,bool b; istringstream buf("tr"); buf>> boolalpha>> b; sets botheofbit andfailbit: there was not enough characters to complete the parsing of the booleantrue.
      • The character extraction overloads ofoperator>>std::basic_istream, if the end of the stream is reached before the limit (if any) on the number of characters to be extracted.
      • Thestd::get_time I/O manipulator and any of thestd::time_get parsing functions:time_get::get,time_get::get_time,time_get::get_date, etc., if the end of the stream is reached before the last character needed to parse the expected date/time value was processed.
      • Thestd::get_money I/O manipulator andmoney_get::get function, if the end of the stream is reached before the last character needed to parse the expected monetary value was processed.
      • Thebasic_istream::sentry constructor, executed at the beginning of every formatted input function: unless theskipws bit is unset (e.g. by issuingstd::noskipws), sentry reads and discards the leading whitespace characters. If the end of the input stream is reached during this operation, botheofbit andfailbit are set, and no input takes place.
      • The I/O manipulatorstd::ws, if it reaches the end of the stream while consuming whitespace (but, unlike the formatted input sentry, it does not setfailbit in this case).
      • The unformatted input functionsbasic_istream::read,basic_istream::get,basic_istream::peek,basic_istream::readsome,basic_istream::ignore, andbasic_istream::getline, when reaching the end of the stream.
      • The discard input functionbasic_istream::ignore, when reaching the end of the stream before reaching the specified delimiter character.
      • The immediate input functionbasic_istream::readsome, ifbasic_streambuf::in_avail returns-1.

      The following functions cleareofbit as a side-effect:

      Note that in nearly all situations, if eofbit is set, the failbit is set as well.

      [edit]The failbit

      The failbit is set by the following standard library functions:

      [edit]The badbit

      The badbit is set by the following standard library functions:

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      The following table shows the value ofbasic_ios accessors (good(),fail(), etc.) for all possible combinations ofios_base::iostate flags:

      ios_base::iostate flagsbasic_ios accessors
      eofbitfailbitbadbitgood()fail()bad()eof()operator booloperator!
      false false falsetrue false false falsetrue false
      false falsetrue falsetruetrue false falsetrue
      falsetrue false falsetrue false false falsetrue
      falsetruetrue falsetruetrue false falsetrue
      true false false false false falsetruetrue false
      true falsetrue falsetruetruetrue falsetrue
      truetrue false falsetrue falsetrue falsetrue
      truetruetrue falsetruetruetrue falsetrue
      returns state flags
      (public member function ofstd::basic_ios<CharT,Traits>)[edit]
      sets state flags
      (public member function ofstd::basic_ios<CharT,Traits>)[edit]
      modifies state flags
      (public member function ofstd::basic_ios<CharT,Traits>)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/ios_base/iostate&oldid=148278"

      [8]ページ先頭

      ©2009-2025 Movatter.jp