I/O manipulators | ||||
Print functions(C++23) | ||||
C-style I/O | ||||
Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
Streams | ||||
Abstractions | ||||
File I/O | ||||
String I/O | ||||
Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
Synchronized Output | ||||
(C++20) | ||||
Types | ||||
Error category interface | ||||
(C++11) | ||||
(C++11) |
Public member functions | ||||
(C++11) | ||||
(C++11) | ||||
(C++26) | ||||
basic_filebuf::is_open | ||||
Protected member functions | ||||
Non-member functions | ||||
(C++11) |
bool is_open()const; | ||
Returnstrue if the most recent call toopen() succeeded and there has been no call toclose() since then.
Contents |
(none)
true if the associated file is open,false otherwise.
This function is typically called bystd::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';}
Output:
direct call: truethrough streambuf: truethrough fstream: true
opens a file and configures it as the associated character sequence (public member function)[edit] | |
flushes the put area buffer and closes the associated file (public member function)[edit] |