Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::resetiosflags

      From cppreference.com
      <cpp‎ |io‎ |manip
       
       
       
      Input/output manipulators
      Floating-point formatting
      Integer formatting
      Boolean formatting
      Field width and fill control
      Other formatting
      Whitespace processing
      Output flushing
      Status flags manipulation
      resetiosflags
      Time and money I/O
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      Quoted manipulator
      (C++14)
       
      Defined in header<iomanip>
      /*unspecified*/ resetiosflags(std::ios_base::fmtflags mask);

      When used in an expressionout<< resetiosflags(mask) orin>> resetiosflags(mask), clears all format flags of the streamout orin as specified by themask.

      Contents

      [edit]Parameters

      mask - bitmask of the flags to clear

      [edit]Return value

      An object of unspecified type such that

      • ifout is an object of typestd::basic_ostream<CharT, Traits>, the expressionout<< resetiosflags(mask)
        • has typestd::basic_ostream<CharT, Traits>&
        • has valueout
        • behaves as if it calledf(out, mask)
      • ifin is an object of typestd::basic_istream<CharT, Traits>, the expressionin>> resetiosflags(mask)
        • has typestd::basic_istream<CharT, Traits>&
        • has valuein
        • behaves as if it calledf(in, mask)

      where the functionf is defined as:

      void f(std::ios_base& str,std::ios_base::fmtflags mask){// reset specified flags    str.setf(ios_base::fmtflags(0), mask);}

      [edit]Example

      Run this code
      #include <iomanip>#include <iostream>#include <sstream> int main(){std::istringstream in("10 010 10 010 10 010");int n1, n2;     in>>std::oct>> n1>> n2;std::cout<<"Parsing\"10 010\" with std::oct gives: "<< n1<<' '<< n2<<'\n';     in>>std::dec>> n1>> n2;std::cout<<"Parsing\"10 010\" with std::dec gives: "<< n1<<' '<< n2<<'\n';     in>> std::resetiosflags(std::ios_base::basefield)>> n1>> n2;std::cout<<"Parsing\"10 010\" with autodetect gives: "<< n1<<' '<< n2<<'\n';}

      Output:

      Parsing "10 010" with std::oct gives: 8 8Parsing "10 010" with std::dec gives: 10 10Parsing "10 010" with autodetect gives: 10 8

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      LWG 183C++98resetiosflags could only be used with
      streams of typestd::ostream orstd::istream
      usable with any
      character stream

      [edit]See also

      sets specific format flag
      (public member function ofstd::ios_base)[edit]
      sets the specifiedios_base flags
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/manip/resetiosflags&oldid=159181"

      [8]ページ先頭

      ©2009-2025 Movatter.jp