• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    function
    <fstream>

    std::basic_filebuf::is_open

    bool is_open() const;
    

    概要

    開いている状態であることの判定をする。

    戻り値

    直前のopenの呼び出しが成功していて(nullptrではない値を返していて)、かつ閉じるような操作が行われていなければtrueを返す。

    #include <iostream>
    #include <fstream>
    
    int main()
    {
      std::fstream fs("foo", std::ios_base::out);
      std::filebuf* buf = fs.rdbuf();
    
      if (buf->is_open()) {
          std::cout << "opened" << std::endl;
      }
    }
    

    出力

    opened
    

    バージョン

    言語

    • C++98