Namespaces
Variants

std::basic_filebuf<CharT,Traits>:: is_open

From cppreference.net
bool is_open ( ) const ;

true 를 반환합니다, 만약 open() 에 대한 가장 최근 호출이 성공했고 그 이후로 close() 호출이 없었다면.

목차

매개변수

(없음)

반환값

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)
put 영역 버퍼를 플러시하고 연결된 파일을 닫습니다
(public member function)