Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::setiosflags

      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
      setiosflags
      Time and money I/O
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      Quoted manipulator
      (C++14)
       
      Defined in header<iomanip>
      /*unspecified*/ setiosflags(std::ios_base::fmtflags mask);

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

      Contents

      [edit]Parameters

      mask - bitmask of the flags to set

      [edit]Return value

      An object of unspecified type such that

      • ifout is an object of typestd::basic_ostream<CharT, Traits>, the expressionout<< setiosflags(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>> setiosflags(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){// set specified flags    str.setf(mask);}

      [edit]Example

      Run this code
      #include <iomanip>#include <iostream> int main(){std::cout<<std::resetiosflags(std::ios_base::dec)<< std::setiosflags(std::ios_base::hex|std::ios_base::uppercase|std::ios_base::showbase)<<42<<'\n';}

      Output:

      0X2A

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      LWG 183C++98setiosflags 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]
      clears the specified ios_base flags
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/manip/setiosflags&oldid=159184"

      [8]ページ先頭

      ©2009-2025 Movatter.jp