std::basic_filebuf<CharT,Traits>::is_open
提供: cppreference.com
< cpp | io | basic filebuf
bool is_open() const; |
||
最も最近の open() の呼び出しが成功し、その後 close() の呼び出しがなければ true を返します。
目次 |
[編集] 引数
(なし)
[編集] 戻り値
紐付けられているファイルが開いていれば true、そうでなければ false。
[編集] ノート
この関数は一般的に std::basic_fstream::is_open() によって呼ばれます。
[編集] 例
Run this code
#include <fstream> #include <iostream> int main() { std::ifstream fs("test.txt"); std::filebuf fb; fb.open("test.txt", std::ios_base::in); std::cout << std::boolalpha << "direct call: " << fb.is_open() << '\n' << "through streambuf: " << fs.rdbuf()->is_open() << '\n' << "through fstream: " << fs.is_open() << '\n'; }
出力:
direct call: true through streambuf: true through fstream: true
[編集] 関連項目
ファイルを開き、それを文字シーケンスとして紐付けます (パブリックメンバ関数) | |
put 領域のバッファをフラッシュし、紐付けられているファイルを閉じます (パブリックメンバ関数) |