std::basic_filebuf<CharT,Traits>:: is_open
From cppreference.net
<
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 member function) |
|
|
出力エリアバッファをフラッシュし、関連付けられたファイルを閉じます
(public member function) |