Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

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

      From cppreference.com
      <cpp‎ |io‎ |basic filebuf
       
       
       
       
      bool is_open()const;

      Returnstrue if the most recent call toopen() succeeded and there has been no call toclose() since then.

      Contents

      [edit]Parameters

      (none)

      [edit]Return value

      true if the associated file is open,false otherwise.

      [edit]Notes

      This function is typically called bystd::basic_fstream::is_open().

      [edit]Example

      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';}

      Output:

      direct call: truethrough streambuf: truethrough fstream: true

      [edit]See also

      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]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_filebuf/is_open&oldid=64259"

      [8]ページ先頭

      ©2009-2025 Movatter.jp