Namespaces
Variants
Views
Actions

std::basic_streambuf::~basic_streambuf

From cppreference.com
< cpp‎ | io‎ | basic streambuf
Revision as of 18:51, 2 November 2012 by P12bot (Talk | contribs)

 
 
 
 

Template:ddcl list begin <tr class="t-dcl ">

<td class="t-dcl-nopad">
virtual ~basic_streambuf();
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

This destruction is empty: the members of this basic_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 from std::basic_streambuf to be deleted through a pointer to base class.

Parameters

(none)

Example

#include <iostream>
#include <fstream>
 
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


See also

Template:cpp/io/basic streambuf/dcl list basic streambuf