std::basic_filebuf<CharT,Traits>::is_open
From cppreference.com
< cpp | io | basic filebuf
| bool is_open() const; |
||
直近の open() の呼び出しが成功し、それ以降 close() が呼び出されていない場合に true を返します。
目次 |
[編集] パラメータ
(なし)
[編集] 戻り値
関連付けられたファイルが開かれている場合は true、そうでない場合は false。
[編集] 注釈
std::basic_fstream::is_open() によって通常呼び出されます。
[編集] 例
このコードを実行
#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
[編集] 関連項目
| ファイルをオープンし、関連付けられた文字シーケンスとして設定します。 (public メンバ関数) | |
| 書き込み領域バッファをフラッシュし、関連付けられたファイルを閉じる (public member function) |