Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::basic_streambuf<CharT,Traits>::~basic_streambuf

      From cppreference.com
      <cpp‎ |io‎ |basic streambuf
       
       
       
      std::basic_streambuf
       
      virtual ~basic_streambuf();

      This destructor has no effect: the members of thisbasic_streambuf (the pointers and the locale) are destructed in accordance with the usual object destruction sequence after this destructor returns. However, since it is declared public virtual, it allows the objects that are derived fromstd::basic_streambuf to be deleted through a pointer to base class.

      Contents

      [edit]Parameters

      (none)

      [edit]Example

      Run this code
      #include <fstream>#include <iostream> int main(){std::filebuf* fbp= newstd::filebuf;    fbp->open("test.txt",std::ios_base::out);    fbp->sputn("Hello\n",6); std::streambuf* sbp= fbp;    delete sbp;// the file is closed, output flushed and written std::ifstream f("test.txt");std::cout<< f.rdbuf();// proof}

      Output:

      Hello

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 54C++98the effect of the destructor was not specifiedspecified as no effect

      [edit]See also

      constructs abasic_streambuf object
      (protected member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_streambuf/%7Ebasic_streambuf&oldid=158555"

      [8]ページ先頭

      ©2009-2025 Movatter.jp