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

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

This destructor has no effect: the members of this basic_streambuf std::basic_streambuf

Parameters

(none)

Example

#include <fstream>
#include <iostream>
 
int main()
{
    std::filebuf* fbp = new std::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

Defect reports

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

See also

constructs a basic_streambuf object
(protected member function)