Namespaces
Variants

Standard library header <ios>

From cppreference.net
Standard library headers

このヘッダは Input/Output ライブラリの一部です。

HTMLタグ、属性、C++コード内のテキストは翻訳せず、元のフォーマットを保持しています。

目次

Includes

入出力ライブラリの全クラスの前方宣言

クラス

書式フラグと入出力例外を管理する
(クラス)
任意のストリームバッファを管理する
(クラステンプレート)
std::ios std:: basic_ios < char > (typedef)
std::wios std:: basic_ios < wchar_t > (typedef)
ストリームまたはファイル内の絶対位置を表す
(クラステンプレート)
(C++11)
IOストリームエラーコード
(列挙型)
型特性 std::is_error_code_enum を拡張して、iostreamエラーコードを識別する
(クラステンプレートの特殊化)
相対的なファイル/ストリーム位置(fposからのオフセット)を表し、任意のファイルサイズを表現するのに十分
(typedef)
I/O操作で転送される文字数またはI/Oバッファのサイズを表す
(typedef)

関数

iostreamエラーカテゴリを識別する
(関数)
iostreamエラーコードを構築する
(関数)
iostreamエラー条件を構築する
(関数)
ブーリアンのテキスト表現と数値表現を切り替える
(関数)
数値の基数を示すためのプレフィックスを使用するかどうかを制御する
(関数)
浮動小数点表現で小数点を常に含めるかどうかを制御する
(function)
非負数に使用される + 符号の表示を制御する
(関数)
入力時に先行する空白をスキップするかどうかを制御します
(関数)
一部の出力形式で大文字を使用するかどうかを制御する
(function)
各操作の後に出力がフラッシュされるかどうかを制御する
(function)
フィル文字の配置を設定する
(関数)
整数I/Oで使用する基数を変更する
(関数)
浮動小数点I/Oで使用される書式を変更する
(関数)

概要

#include <iosfwd>
namespace std {
  using streamoff  = /* 実装定義 */;
  using streamsize = /* 実装定義 */;
  template<class StateT> class fpos;
  class ios_base;
  template<class CharT, class Traits = char_traits<CharT>>
    class basic_ios;
  // マニピュレータ
  ios_base& boolalpha  (ios_base& str);
  ios_base& noboolalpha(ios_base& str);
  ios_base& showbase   (ios_base& str);
  ios_base& noshowbase (ios_base& str);
  ios_base& showpoint  (ios_base& str);
  ios_base& noshowpoint(ios_base& str);
  ios_base& showpos    (ios_base& str);
  ios_base& noshowpos  (ios_base& str);
  ios_base& skipws     (ios_base& str);
  ios_base& noskipws   (ios_base& str);
  ios_base& uppercase  (ios_base& str);
  ios_base& nouppercase(ios_base& str);
  ios_base& unitbuf    (ios_base& str);
  ios_base& nounitbuf  (ios_base& str);
  // 調整フィールド
  ios_base& internal   (ios_base& str);
  ios_base& left       (ios_base& str);
  ios_base& right      (ios_base& str);
  // 基数フィールド
  ios_base& dec        (ios_base& str);
  ios_base& hex        (ios_base& str);
  ios_base& oct        (ios_base& str);
  // 浮動小数点フィールド
  ios_base& fixed      (ios_base& str);
  ios_base& scientific (ios_base& str);
  ios_base& hexfloat   (ios_base& str);
  ios_base& defaultfloat(ios_base& str);
  // エラー報告
  enum class io_errc {
    stream = 1
  };
  template<> struct is_error_code_enum<io_errc> : public true_type { };
  error_code make_error_code(io_errc e) noexcept;
  error_condition make_error_condition(io_errc e) noexcept;
  const error_category& iostream_category() noexcept;
}

クラス std::ios_base

namespace std {
  class ios_base {
  public:
    class failure;              // 説明を参照
    // fmtflags
    using fmtflags = /*ビットマスク型-1*/;
    static constexpr fmtflags boolalpha = /* 未指定 */;
    static constexpr fmtflags dec = /* 未指定 */;
    static constexpr fmtflags fixed = /* 未指定 */;
    static constexpr fmtflags hex = /* 未指定 */;
    static constexpr fmtflags internal = /* 未指定 */;
    static constexpr fmtflags left = /* 未指定 */;
    static constexpr fmtflags oct = /* 未指定 */;
    static constexpr fmtflags right = /* 未指定 */;
    static constexpr fmtflags scientific = /* 未指定 */;
    static constexpr fmtflags showbase = /* 未指定 */;
    static constexpr fmtflags showpoint = /* 未指定 */;
    static constexpr fmtflags showpos = /* 未指定 */;
    static constexpr fmtflags skipws = /* 未指定 */;
    static constexpr fmtflags unitbuf = /* 未指定 */;
    static constexpr fmtflags uppercase = /* 未指定 */;
    static constexpr fmtflags adjustfield = /* 説明を参照 */;
    static constexpr fmtflags basefield = /* 説明を参照 */;
    static constexpr fmtflags floatfield = /* 説明を参照 */;
    // iostate
    using iostate = /*ビットマスク型-2*/;
    static constexpr iostate badbit = /* 未指定 */;
    static constexpr iostate eofbit = /* 未指定 */;
    static constexpr iostate failbit = /* 未指定 */;
    static constexpr iostate goodbit = /* 説明を参照 */;
    // openmode
    using openmode = /*ビットマスク型-3*/;
    static constexpr openmode app = /* 未指定 */;
    static constexpr openmode ate = /* 未指定 */;
    static constexpr openmode binary = /* 未指定 */;
    static constexpr openmode in = /* 未指定 */;
    static constexpr openmode out = /* 未指定 */;
    static constexpr openmode trunc = /* 未指定 */;
    static constexpr openmode noreplace = /* 未指定 */
    // seekdir
    using seekdir = /*ビットマスク型-4*/;
    static constexpr seekdir beg = /* 未指定 */;
    static constexpr seekdir cur = /* 未指定 */;
    static constexpr seekdir end = /* 未指定 */;
    class Init;
    // fmtflags 状態
    fmtflags flags() const;
    fmtflags flags(fmtflags fmtfl);
    fmtflags setf(fmtflags fmtfl);
    fmtflags setf(fmtflags fmtfl, fmtflags mask);
    void unsetf(fmtflags mask);
    streamsize precision() const;
    streamsize precision(streamsize prec);
    streamsize width() const;
    streamsize width(streamsize wide);
    // ロケール
    locale imbue(const locale& loc);
    locale getloc() const;
    // ストレージ
    static int xalloc();
    long&  iword(int idx);
    void*& pword(int idx);
    // デストラクタ
    virtual ~ios_base();
    // コールバック
    enum event { erase_event, imbue_event, copyfmt_event };
    using event_callback = void (*)(event, ios_base&, int idx);
    void register_callback(event_callback fn, int idx);
    ios_base(const ios_base&) = delete;
    ios_base& operator=(const ios_base&) = delete;
    static bool sync_with_stdio(bool sync = true);
  protected:
    ios_base();
  private:
    static int index;           // 説明専用
    long*  iarray;              // 説明専用
    void** parray;              // 説明専用
  };
}

クラス std::ios_base::failure

namespace std {
  class ios_base::failure : public system_error {
  public:
    explicit failure(const string& msg, const error_code& ec = io_errc::stream);
    explicit failure(const char* msg, const error_code& ec = io_errc::stream);
  };
}
**注記**: 提供されたコードはC++の標準ライブラリコードであり、HTMLタグ内の タグで囲まれた部分は翻訳対象外です。上記のコードブロックには翻訳すべき自然言語テキストが含まれていないため、そのまま出力しています。

クラス std::ios_base::Init

namespace std {
  class ios_base::Init {
  public:
    Init();
    Init(const Init&) = default;
    ~Init();
    Init& operator=(const Init&) = default;
  private:
    static int init_cnt;        // 説明専用
  };
}

クラステンプレート std::fpos

namespace std {
  template<class StateT> class fpos {
  public:
    // メンバー
    StateT state() const;
    void state(stateT);
  private;
    StateT st;                  // 説明専用
  };
}

クラステンプレート std::basic_ios

namespace std {
  template<class CharT, class Traits = char_traits<CharT>>
  class basic_ios : public ios_base {
  public:
    using char_type   = CharT;
    using int_type    = typename Traits::int_type;
    using pos_type    = typename Traits::pos_type;
    using off_type    = typename Traits::off_type;
    using traits_type = Traits;
    // フラグ関数
    explicit operator bool() const;
    bool operator!() const;
    iostate rdstate() const;
    void clear(iostate state = goodbit);
    void setstate(iostate state);
    bool good() const;
    bool eof()  const;
    bool fail() const;
    bool bad()  const;
    iostate exceptions() const;
    void exceptions(iostate except);
    // コンストラクタ/デストラクタ
    explicit basic_ios(basic_streambuf<CharT, Traits>* sb);
    virtual ~basic_ios();
    // メンバ関数
    basic_ostream<CharT, Traits>* tie() const;
    basic_ostream<CharT, Traits>* tie(basic_ostream<CharT, Traits>* tiestr);
    basic_streambuf<CharT, Traits>* rdbuf() const;
    basic_streambuf<CharT, Traits>* rdbuf(basic_streambuf<CharT, Traits>* sb);
    basic_ios& copyfmt(const basic_ios& rhs);
    char_type fill() const;
    char_type fill(char_type ch);
    locale imbue(const locale& loc);
    char      narrow(char_type c, char dfault) const;
    char_type widen(char c) const;
    basic_ios(const basic_ios&) = delete;
    basic_ios& operator=(const basic_ios&) = delete;
  protected:
    basic_ios();
    void init(basic_streambuf<CharT, Traits>* sb);
    void move(basic_ios& rhs);
    void move(basic_ios&& rhs);
    void swap(basic_ios& rhs) noexcept;
    void set_rdbuf(basic_streambuf<CharT, Traits>* sb);
  };
}

不具合報告

以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。

DR 適用対象 公開時の動作 正しい動作
LWG 35 C++98 unitbuf および nounitbuf のプロトタイプが概要から欠落していた 追加された
LWG 78 C++98 ios_base::register_callback のパラメータ fn の型が概要で誤って指定されていた
event_call_back と記述)
以下のように修正
event_callback