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) |
|
|
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 |
(none)
#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
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 54 | C++98 | the effect of the destructor was not specified | specified as no effect |
constructs abasic_streambuf object(protected member function)[edit] |