命名空间
变体
操作

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

来自 cppreference.com
< cpp‎ | io‎ | basic ostream
 
 
 
 
virtual ~basic_ostream();

销毁 basic_ostream 对象。此析构函数不会对底层流缓冲区 (rdbuf()) 执行任何操作:派生输出流(例如 std::basic_ofstreamstd::basic_ostringstream)的析构函数负责调用流缓冲区的析构函数。

[编辑] 示例

#include <iostream>
#include <sstream>
 
void add_words(std::streambuf* p)
{
    std::ostream buf(p); // buf shares the buffer with s
    buf << " is the answer";
} // calls the destructor of buf. p remains unaffected
 
int main()
{
    std::ostringstream s;
    s << 42;
    add_words(s.rdbuf());
    s << ".";
    std::cout << s.str() << '\n';
}

输出

42 is the answer.